2015-12-15 52 views
0

使用SonarQube 5.2和Sonar-Java-Plugin 3.8,並使用Sonar-Runner 2.4進行分析。SonarQube 5.2 - 針對自定義Java規則未鎖定的問題

從git(https://github.com/SonarSource/sonar-examples/tree/master/plugins/java-custom-rules)下載插件和java-custom示例,在服務器上構建和部署,並且規則在服務器上可見。規則在「Sonar Way」配置文件(默認)下使用網絡激活。還會創建一個新的測試配置文件,並添加規則「避免方法名稱中的品牌」,並將項目與其關聯。

在分析來自(/ src/test/files)的示例java代碼時,來自所有默認java規則的問題都被鎖定在服務器上,但是沒有爲自定義規則鎖定問題。日誌中也沒有明確的錯誤。

sonar-runner.properties

sonar.host.url=http://localhost:9000 
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar52?useUnicode=true&characterEncoding=utf8 
sonar.jdbc.username=root 
sonar.jdbc.password=ChangeIt 
sonar.projectKey=TestSonarCustomRules 
sonar.projectName=TestSonarCustomRules 
sonar.projectVersion=1.0 
sonar.sources=E:/Sonar Example/sonar-examples-master/plugins/java-custom-rules/src/test/files/ 

下面是分析日誌:

E:\sonar-runner-2.4 
SonarQube Runner 2.4 
Java 1.8.0_45 Oracle Corporation (64-bit) 
Windows 7 6.1 amd64 
INFO: Runner configuration file: E:\sonar-runner-2.4\conf\sonar-runner.properties 
INFO: Project configuration file: NONE 
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent) 
INFO: Work directory: E:\Sonar Example\sonar-examples-master\plugins\java-custom-rules\src\test\files\.\.sonar 
INFO: SonarQube Server 5.2 
18:56:49.391 INFO - Load global repositories 
18:56:49.539 INFO - Load global repositories (done) | time=145ms 
18:56:49.557 WARN - Property 'sonar.jdbc.url' is not supported any more. There is no more DB connection to the SQ database. It will be ignored. 
18:56:49.558 WARN - Property 'sonar.jdbc.username' is not supported any more. There is no more DB connection to the SQ database. It will be ignored. 
18:56:49.558 WARN - Property 'sonar.jdbc.password' is not supported any more. There is no more DB connection to the SQ database. It will be ignored. 
18:56:49.560 INFO - User cache: C:\Users\kapil.saxena\.sonar\cache 
18:56:49.777 INFO - Load plugins index 
18:56:49.781 INFO - Load plugins index (done) | time=4ms 
18:56:49.960 INFO - Process project properties 
18:56:50.209 INFO - Load project repositories 
18:56:50.290 INFO - Load project repositories (done) | time=81ms 
18:56:50.298 INFO - Apply project exclusions 
18:56:50.369 INFO - Load quality profiles 
18:56:50.401 INFO - Load quality profiles (done) | time=32ms 
18:56:50.403 INFO - Load active rules 
18:56:50.478 INFO - Load active rules (done) | time=75ms 
18:56:50.498 WARN - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.provider to define SCM of your project. 
18:56:50.499 INFO - Publish mode 
18:56:50.500 INFO - ------------- Scan TestSonarCustomRules 
18:56:50.582 INFO - Load server rules 
18:56:50.630 INFO - Load server rules (done) | time=48ms 
18:56:50.683 INFO - Base dir: E:\Sonar Example\sonar-examples-master\plugins\java-custom-rules\src\test\files 
18:56:50.683 INFO - Working dir: E:\Sonar Example\sonar-examples-master\plugins\java-custom-rules\src\test\files\.sonar 
18:56:50.685 INFO - Source paths: . 
18:56:50.685 INFO - Source encoding: windows-1252, default locale: en_US 
18:56:50.686 INFO - Index files 
18:56:50.758 INFO - 7 files indexed 
18:56:50.760 INFO - Quality profile for java: Kapil Test Profile 
18:56:50.786 INFO - Sensor JavaSquidSensor 
18:56:50.925 INFO - Configured Java source version: none 
18:56:50.954 INFO - JavaClasspath initialization... 
18:56:50.954 INFO - JavaClasspath initialization done: 0 ms 
18:56:50.954 INFO - JavaTestClasspath initialization... 
18:56:50.954 INFO - JavaTestClasspath initialization done: 0 ms 
18:56:51.232 INFO - Java Main Files AST scan... 
18:56:51.234 INFO - 7 source files to be analyzed 
18:56:51.631 INFO - 7/7 source files have been analyzed 
18:56:51.632 INFO - Java Main Files AST scan done: 400 ms 
18:56:51.632 WARN - Java bytecode has not been made available to the analyzer. The [email protected] are disabled. 
18:56:51.632 INFO - Java Test Files AST scan... 
18:56:51.632 INFO - 0 source files to be analyzed 
18:56:51.632 INFO - Java Test Files AST scan done: 0 ms 
18:56:51.632 INFO - 0/0 source files have been analyzed 
18:56:51.632 INFO - Sensor JavaSquidSensor (done) | time=846ms 
18:56:51.633 INFO - Sensor Lines Sensor 
18:56:51.635 INFO - Sensor Lines Sensor (done) | time=2ms 
18:56:51.635 INFO - Sensor QProfileSensor 
18:56:51.640 INFO - Sensor QProfileSensor (done) | time=5ms 
18:56:51.640 INFO - Sensor SurefireSensor 
18:56:51.641 INFO - parsing E:\Sonar Example\sonar-examples-master\plugins\java-custom-rules\src\test\files\target\surefire-reports 
18:56:51.641 ERROR - Reports path not found or is not a directory: E:\Sonar Example\sonar-examples-master\plugins\java-custom-rules\src\test\files\target\surefire-reports 
18:56:51.641 INFO - Sensor SurefireSensor (done) | time=1ms 
18:56:51.641 INFO - Sensor SCM Sensor 
18:56:51.641 INFO - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it. 
18:56:51.641 INFO - Sensor SCM Sensor (done) | time=0ms 
18:56:51.641 INFO - Sensor Code Colorizer Sensor 
18:56:51.642 INFO - Sensor Code Colorizer Sensor (done) | time=1ms 
18:56:51.642 INFO - Sensor CPD Sensor 
18:56:51.642 INFO - JavaCpdEngine is used for java 
18:56:51.682 INFO - Sensor CPD Sensor (done) | time=40ms 
18:56:51.752 INFO - Analysis reports generated in 68ms, dir size=9 KB 
18:56:51.873 INFO - Analysis reports compressed in 121ms, zip size=11 KB 
18:56:51.912 INFO - Analysis reports sent to server in 38ms 
18:56:51.913 INFO - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/TestSonarCustomRules 
18:56:51.913 INFO - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report. 
18:56:51.913 INFO - More about the report processing at http://localhost:9000/api/ce/task?id=AVGl0nT8XJ_fdu5L48WL 
INFO: ------------------------------------------------------------------------ 
INFO: EXECUTION SUCCESS INFO: 
------------------------------------------------------------------------ 
Total time: 3.290s Final Memory: 14M/325M INFO: 
------------------------------------------------------------------------ 

聲納,訪問和包裝日誌都是乾淨的。

下面是SonarQube網頁顯示問題圖像AvoidBrandInMethodNamesChecks,在默認情況下所有的問題都被鎖定,但對自定義規則問題沒有被鎖定: Issues for AvoidBrandInMethodNamesCheck

任何幫助,將不勝感激。

+0

我懷疑自定義java規則(雖然在缺省QP中激活,並且在調試服務器啓動期間顯示要添加的插件)在分析期間未被拾取;因爲我有意在規則的scanFile方法中放置了一個異常,但它不會被拋出,並且都不打印日誌。 –

回答

0

當使用verbose/DEBUG進行日誌級別分析時,自定義插件代碼的調試語句未執行。

行爲是一樣的,當分析,使用SonarQube 5.1/5.2/5.3對嵌入式H2/PostgreSQL的9.5

+0

如果這是試圖回答這個問題,也許你應該詳細說明這個問題,比如更多地闡明它,連接資源或描述必要的步驟。 – dakab

0

終於摸索數據庫默認已完成。我使用的是錯誤版本的例子。我的java-custom-rules的pom.xml文件沒有以下內容:

<dependency> 
    <groupId>org.sonarsource.java</groupId> 
    <artifactId>java-squid</artifactId> 
    <version>${java.plugin.version}</version> 
</dependency> 

注意:獲取最新版本的示例。

相關問題