Tôi đã đọc tài liệu về loại trừ, đã thử một số kết hợp, nhưng vẫn Sonar đang phân tích mã mà nó không được yêu cầu. Sau đây là một mẫu của tập tin sonar-runner.properties tôi:Loại trừ Sonar không ngăn phân tích mã C#
#----- Required metadata
sonar.projectKey=ProjectKey
sonar.projectName=ProjectName
sonar.projectVersion=1.0
sonar.sources=MySourceFolder
sonar.build-stability.url=-
sonar.language=cs
sonar.dotnet.visualstudio.solution.file=MySourceFolder\\Solution.sln
sonar.donet.visualstudio.testProjectPattern=*.Tests*
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
#----- Default Sonar server
sonar.host.url=http://myserver
#----- MySQL
sonar.jdbc.url=jdbc:mysql://myserver:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
sonar.jdbc.driver=com.mysql.jdbc.Driver
#----- Global database settings
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
#----- Static analysis
sonar.fxcop.installDirectory=C:/Program Files (x86)/Microsoft Fxcop 10.0
tùy chọn cuối tôi được sử dụng là để cấu hình các loại trừ thông qua giao diện người dùng Sonar (Cài đặt Project> Exclusions> Source File Exclusions) và thiết lập một giá trị như sau:
MySourceFolder/FolderA/FolderB/*.cs
trong các bản ghi tôi thấy thông báo sau:
[17:27:10][Step 7/9] 17:27:10.919 INFO - Excluded sources:
[17:27:10][Step 7/9] 17:27:10.919 INFO - MySourceFolder/FolderA/FolderB/*.cs
Tuy nhiên, i mã đang được phân tích như nó xuất hiện trong phạm sonar và trùng lặp s plugins thông tin.
Bất kỳ ý tưởng nào về những gì có thể gây ra hành vi này hoặc cách định cấu hình đúng loại trừ cho tệp C#?
Cảm ơn rất nhiều!
Ricardo
Tôi có cùng sự cố và khi sử dụng 'sonar.sources = js sonar.exclusions = js/blah/**' Tôi có thể thấy "Nguồn bị loại trừ" trong nhật ký Jenkins, nhưng sau đó các tệp trong blah thư mục hiển thị trong phân tích. Bất kỳ gợi ý nào? Tôi cũng đã thêm loại trừ thông qua giao diện SonarQube (dự án-cấu hình-cài đặt-loại trừ), nhưng kết quả tương tự. – Stephan
Thực ra, sau một lần thử khác, nó hoạt động với tôi bằng cách sử dụng cú pháp 'file: **/blah/**'. Xin lỗi vì điều đó! :) – Stephan