Code coverage for Manual Regression using sonar and jacoco - ant

I am trying to generate code coverage for webapp for manual testing using jacoco and sonar.
I am able to generate jacoco.exec file by modifying the catalina.bat in following way:
SET JACOCO=-javaagent:\jacoco-0.7.5.201505241946\lib\jacocoagent.jar=destfile=C:\jacoco.exec,append=true,includes=*
set JAVA_OPTS=%JAVA_OPTS% %JACOCO%
I then copy the jacoco.exec file to a target folder inside sonarcube and run ant sonar. The build.xml has following entries:
<!-- The following properties are required to use JaCoCo: -->
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<property name="sonar.java.coveragePlugin" value="jacoco" />
<property name="sonar.jacoco.reportPath" value="target/jacoco.exec" />
<!-- Define the SonarQube target -->
<target name="sonar">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<!-- Update the following line, or put the "sonar-ant-task-*.jar" file in your "$HOME/.ant/lib" folder -->
<classpath path="../apache-ant-1.9.6/lib/sonar-ant-task-2.3.jar"/>
</taskdef>
<!-- Execute the SonarQube analysis -->
<sonar:sonar/>
</target>
</project>
The output I get from ant if following. I don't see any coverage in the report at the url
http://localhost:9000/dashboard/index/org.codehaus.sonar:example-java-ant
Am I missing something?
c:\sonarqube>ant sonar
Buildfile: c:\sonarqube\build.xml
sonar:
[sonar:sonar] Apache Ant(TM) version 1.9.6 compiled on June 29 2015
[sonar:sonar] SonarQube Ant Task version: 2.3
[sonar:sonar] Loaded from: file:/C:/apache-ant-1.9.6/lib/sonar-ant-task-2.3.jar
[sonar:sonar] INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
[sonar:sonar] INFO: Work directory: c:\sonarqube\.sonar
[sonar:sonar] INFO: SonarQube Server 5.2
[sonar:sonar] 17:18:52.370 INFO - Load global repositories
[sonar:sonar] 17:18:52.959 INFO - Load global repositories (done) | time=588ms
[sonar:sonar] 17:18:53.034 INFO - User cache: C:\Users\Administrator\.sonar\cache
[sonar:sonar] 17:18:53.932 INFO - Load plugins index
[sonar:sonar] 17:18:53.952 INFO - Load plugins index (done) | time=20ms
[sonar:sonar] 17:18:54.677 INFO - Process project properties
[sonar:sonar] 17:18:57.381 INFO - Load project repositories
[sonar:sonar] 17:18:57.493 INFO - Load project repositories (done) | time=112ms
[sonar:sonar] 17:18:57.535 INFO - Apply project exclusions
[sonar:sonar] 17:18:57.667 INFO - Load quality profiles
[sonar:sonar] 17:18:57.983 INFO - Load quality profiles (done) | time=315ms
[sonar:sonar] 17:18:58.039 INFO - Load active rules
[sonar:sonar] 17:19:00.610 INFO - Load active rules (done) | time=2571ms
[sonar:sonar] 17:19:00.636 WARN - 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[sonar:sonar] 17:19:00.797 WARN - SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.
scm.provider to define SCM of your project.
[sonar:sonar] 17:19:00.800 INFO - Publish mode
[sonar:sonar] 17:19:00.805 INFO - ------------- Scan Simple Java Project analyzed with the SonarQube Ant Task
[sonar:sonar] 17:19:01.844 INFO - Language is forced to java
[sonar:sonar] 17:19:01.887 INFO - Load server rules
[sonar:sonar] 17:19:02.373 INFO - Load server rules (done) | time=486ms
[sonar:sonar] 17:19:02.755 INFO - Base dir: c:\sonarqube
[sonar:sonar] 17:19:02.756 INFO - Working dir: c:\sonarqube\.sonar
[sonar:sonar] 17:19:02.781 INFO - Source paths: src
[sonar:sonar] 17:19:02.786 INFO - Source encoding: windows-1252, default locale: en_US
[sonar:sonar] 17:19:02.787 INFO - Index files
[sonar:sonar] 17:19:02.854 INFO - 0 files indexed
[sonar:sonar] 17:19:02.857 INFO - Quality profile for java: Sonar way
[sonar:sonar] 17:19:02.999 INFO - Sensor Lines Sensor
[sonar:sonar] 17:19:03.005 INFO - Sensor Lines Sensor (done) | time=6ms
[sonar:sonar] 17:19:03.006 INFO - Sensor QProfileSensor
[sonar:sonar] 17:19:03.095 INFO - Sensor QProfileSensor (done) | time=89ms
[sonar:sonar] 17:19:03.096 INFO - Sensor SCM Sensor
[sonar:sonar] 17:19:03.097 INFO - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
[sonar:sonar] 17:19:03.100 INFO - Sensor SCM Sensor (done) | time=4ms
[sonar:sonar] 17:19:03.100 INFO - Sensor Code Colorizer Sensor
[sonar:sonar] 17:19:03.106 INFO - Sensor Code Colorizer Sensor (done) | time=6ms
[sonar:sonar] 17:19:03.107 INFO - Sensor CPD Sensor
[sonar:sonar] 17:19:03.108 INFO - JavaCpdEngine is used for java
[sonar:sonar] 17:19:03.110 INFO - Sensor CPD Sensor (done) | time=3ms
[sonar:sonar] 17:19:03.304 INFO - Analysis reports generated in 192ms, dir size=5 KB
[sonar:sonar] 17:19:03.320 INFO - Analysis reports compressed in 15ms, zip size=2 KB
[sonar:sonar] 17:19:03.758 INFO - Analysis reports sent to server in 424ms
[sonar:sonar] 17:19:03.762 INFO - ANALYSIS SUCCESSFUL, you can browse

Looking at log of analysis we cannot see any JaCoCo sensor executed. JaCoCo sensor is executed only if you have java file in your analysis which you don't as you can see per 0 files indexed line in your log.
To explain this behaviour you have to understand that JaCoCo sensor will only report coverage on files indexed so if there are no java files, there is no point to execute it.
So to report and compute coverage you would have to import a coverage report related to some source files you analyze in your project.

Related

ANT Task: SonarQube Scanner Code Coverage report using JaCoCo

I'm using the below property to generate JaCoCo XML report
<property name="sonar.coverage.jacoco.xmlReportPaths" value="${basedir}/sonar-task/reports/jacoco.xml" />
When I invoke this ANT Task from Jenkins, I'm seeing the below exception in Jenkins logs and so I don't see the Code Coverage value in SonarQube
15:09:49 [sonar:sonar] Apache Ant(TM) version 1.10.7 compiled on September 1 2019
15:09:49 [sonar:sonar] SonarQube Ant Task version: 2.6.0.1426
.
.
.
15:14:55 [sonar:sonar] Sensor JavaSquidSensor [java] (done) | time=262215ms
15:14:55 [sonar:sonar] Sensor JaCoCo XML Report Importer [jacoco]
15:14:55 [sonar:sonar] Coverage report 'C:\Softwares\Jenkins\workspace\MYA_DevOps_PIPELINE\.\sonar-task\reports\jacoco.xml' could not be read/imported. Error: {}
15:14:55 [sonar:sonar] java.lang.IllegalStateException: Failed to parse JaCoCo XML report: C:\Softwares\Jenkins\workspace\MYA_DevOps_PIPELINE\.\sonar-task\reports\jacoco.xml
15:14:55 [sonar:sonar] at org.sonar.plugins.jacoco.XmlReportParser.parse(XmlReportParser.java:96)
I can see the HTML reports and I can see the jacoco.xml file is getting generated as well. But the content inside this file is not XML.
Just add the below line while you generate an XML JaCoCo report
<xml destfile="${sonar.coverage.jacoco.xmlReportPaths}"/>

ant sonar - class not found error

I'm seeing the following errors when running ant with sonar. I'm not even using those classes on my code. ANy ideas?
[sonar:sonar] Sensor JavaSquidSensor
[sonar:sonar] Configured Java source version (sonar.java.source): 8
[sonar:sonar] JavaClasspath initialization...
[sonar:sonar] JavaClasspath initialization done: 2603 ms
[sonar:sonar] JavaTestClasspath initialization...
[sonar:sonar] JavaTestClasspath initialization done: 2247 ms
[sonar:sonar] Java Main Files AST scan...
[sonar:sonar] 64 source files to be analyzed
[sonar:sonar] Class not found: javax.annotation.Nullable
[sonar:sonar] Class not found: com.google.errorprone.annotations.CanIgnoreReturnValue
[sonar:sonar] Class not found: com.google.errorprone.annotations.concurrent.LazyInit
[sonar:sonar] Class not found: com.google.j2objc.annotations.RetainedWith
[sonar:sonar] Class not found: javax.annotation.Nullable
[sonar:sonar] Class not found: com.google.errorprone.annotations.CanIgnoreReturnValue
[sonar:sonar] Class not found: com.google.errorprone.annotations.concurrent.LazyInit
[sonar:sonar] Class not found: com.google.j2objc.annotations.RetainedWith
[sonar:sonar] 21/64 files analyzed, current file: xxxx
[sonar:sonar] 63/64 files analyzed, current file: xxxx
[sonar:sonar] Java Main Files AST scan done: 21433 ms
[sonar:sonar] 64/64 source files have been analyzed
[sonar:sonar] Java bytecode scan...
[sonar:sonar] Java bytecode scan done: 464 ms
[sonar:sonar] Java Test Files AST scan...
[sonar:sonar] 7 source files to be analyzed
[sonar:sonar] Java Test Files AST scan done: 1689 ms
[sonar:sonar] 7/7 source files have been analyzed
[sonar:sonar] Package design analysis...
[sonar:sonar] Package design analysis done: 26 ms
[sonar:sonar] Sensor JavaSquidSensor (done) | time=29620ms
[sonar:sonar] Sensor Lines Sensor
[sonar:sonar] Sensor Lines Sensor (done) | time=13ms
[sonar:sonar] Sensor CoberturaSensor
Thank you in advance.
This debug information is likely related to n-th level dependencies. This is info-only and printed as a warning that the analysis might not be as detailed as possible because those binaries weren't available to factor in to it.

Caused by: java.lang.IllegalStateException: The folder 'test' does not exist for

I will need your help please.
This is the context, I'm trying to set up a Continous Integration plateform, for specifc needs, and this is my Configuration, all in the same machine(Windows 7 ):
SonarQube 5.1 (I tried both internal and external databases)
SonarQube runner 2.4
PHP plugin for Sonar
Jenkins 1.6
SonarQube plugin for Jenkins (I'have already done all of the Sonarqube config in Jenkins)
I created a specific Job for PHP (Which is a local folder in my file system)(I configured the build section of Jenkins bu adding Standalone SonarQube Analysis, with the specific Path to projeetc proporties which point to my sonar-project.properties behind )
sonar.projectKey=my:project
sonar.projectName=PHP project analyzed with the SonarQube Runner reusing PHPUnit reports
sonar.projectVersion=1.0
sonar.sources=userthing,test sonar.tests=test sonar.language=php sonar.sourceEncoding=UTF-8 # Reusing PHPUnit reports #sonar.php.coverage.reportPath=reports/phpunit.coverage.xml #sonar.php.tests.reportPath=reports/phpunit.xml
When I launch a build from Jenkins I have this error :
NFO: Work directory: C:\Users\user\.jenkins\jobs\test projet\workspace\.sonar
INFO: SonarQube Server 5.1.2
14:13:10.295 INFO - Load global repositories
14:13:10.372 INFO - Load global repositories (done) | time=78ms
14:13:10.374 INFO - Server id: 20151028133512
14:13:10.374 INFO - User cache: C:\Users\user\.sonar\cache
14:13:10.379 INFO - Install plugins
14:13:10.706 INFO - Install JDBC driver
14:13:10.710 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
14:13:11.247 INFO - Initializing Hibernate
14:13:12.106 ERROR - Invalid value of sonar.tests for my:project
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2.131s
Final Memory: 6M/20M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: The folder 'test' does not exist for 'my:project' (base directory = C:\Users\user\.jenkins\jobs\test projet\workspace)
at org.sonar.batch.scan.ProjectReactorBuilder.checkExistenceOfPaths(ProjectReactorBuilder.java:427)
at org.sonar.batch.scan.ProjectReactorBuilder.validateDirectories(ProjectReactorBuilder.java:334)
at org.sonar.batch.scan.ProjectReactorBuilder.defineRootProject(ProjectReactorBuilder.java:163)
at org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:116)
at org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:110)
at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:86)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
ERROR:
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Lancer une analyse SonarQube autonome' marked build as failure
Finished: FAILURE
I follow those steps to identify the root concern:
I created manually sonar-project.properties.
Lunch sonar-runner.bat directly from my php folder, => then it works perfectly I have all the metric.
I'm sure that the root cause is Jenkins, but I don't know exactly what I'm missing.
Even if some times everything seems to work fine, I got this message from stacktrace
0 file indexed
:
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: C:\DevTools\sonar-runner-2.4\conf\sonar-runner.properties
INFO: Project configuration file: C:\Users\user\Desktop\Exemple de projet PHPUNIT\sonar-project.properties
INFO: Default locale: "fr_FR", source code encoding: "UTF-8"
INFO: Work directory: C:\Users\user\.jenkins\jobs\projet\workspace\.sonar
INFO: SonarQube Server 5.1.2
14:55:20.977 INFO - Load global repositories
14:55:21.040 INFO - Load global repositories (done) | time=63ms
14:55:21.040 INFO - Server id: 20151028133512
14:55:21.040 INFO - User cache: C:\Users\user\.sonar\cache
14:55:21.040 INFO - Install plugins
14:55:21.390 INFO - Install JDBC driver
14:55:21.390 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
14:55:21.918 INFO - Initializing Hibernate
14:55:22.858 INFO - Load project repositories
14:55:23.030 INFO - Load project repositories (done) | time=172ms
14:55:23.030 INFO - Load project settings
14:55:23.326 INFO - Load technical debt model
14:55:23.358 INFO - Apply project exclusions
14:55:23.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.
14:55:23.498 INFO - ------------- Scan My Sonar Analyses for PHP project
14:55:23.498 INFO - Load module settings
14:55:23.576 INFO - Language is forced to php
14:55:23.576 INFO - Load rules
14:55:23.864 INFO - Base dir: C:\Users\user\.jenkins\jobs\projet\workspace
14:55:23.864 INFO - Working dir: C:\Users\user\.jenkins\jobs\projet\workspace\.sonar
14:55:23.864 INFO - Source paths: .
14:55:23.864 INFO - Source encoding: UTF-8, default locale: fr_FR
14:55:23.864 INFO - Index files
14:55:23.866 INFO - **0 files indexed******************************
14:55:23.866 INFO - Quality profile for php: Sonar way
14:55:24.095 INFO - Sensor Lines Sensor
14:55:24.095 INFO - Sensor Lines Sensor (done) | time=0ms
14:55:24.095 INFO - Sensor QProfileSensor
14:55:24.105 INFO - Sensor QProfileSensor (done) | time=10ms
14:55:24.105 INFO - Sensor InitialOpenIssuesSensor
14:55:24.120 INFO - Sensor InitialOpenIssuesSensor (done) | time=15ms
14:55:24.120 INFO - Sensor ProjectLinksSensor
14:55:24.128 INFO - Sensor ProjectLinksSensor (done) | time=8ms
14:55:24.128 INFO - Sensor VersionEventsSensor
14:55:24.133 INFO - Sensor VersionEventsSensor (done) | time=5ms
14:55:24.133 INFO - Sensor SCM Sensor
14:55:24.133 INFO - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
14:55:24.133 INFO - Sensor SCM Sensor (done) | time=0ms
14:55:24.133 INFO - Sensor CPD Sensor
14:55:24.133 INFO - DefaultCpdEngine is used for php
14:55:24.133 INFO - Sensor CPD Sensor (done) | time=0ms
14:55:24.133 INFO - No quality gate is configured.
14:55:24.163 INFO - Compare to previous analysis (2015-10-28)
14:55:24.165 INFO - Compare over 30 days (2015-09-28, analysis of Wed Oct 28 14:39:55 CET 2015)
14:55:24.267 INFO - Execute decorators...
14:55:24.372 INFO - Store results in database
14:55:24.425 INFO - Analysis reports generated in 35ms, dir size=2 KB
14:55:24.435 INFO - Analysis reports compressed in 10ms, zip size=2 KB
14:55:24.459 INFO - Analysis reports sent to server in 23ms
14:55:24.460 INFO - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/projet
14:55:24.460 INFO - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 3.851s
Final Memory: 13M/113M
INFO: ------------------------------------------------------------------------
Finished: SUCCESS
It seems like his enable to index files that I have in my php folder.
Thanks in advance for your help!
I found the root cause, as I suggested in my last comment Jenkis is the root concern, because, I wasn't aware how Jenkins, build non source Controle Projects.
In fact you have to follow those steps in order to copy your projet into Jenkis workspace:
Build the Project at least once, (it will fail), but Jenkins will
create the structure jenkins/workspace/PROJECTNAME/
Copy the project files to jenkins/workspace/PROJECTNAME/
Build again and configure appropriately
For more information in the subject, I will suggest that you look jenkins docs:Builds for Non-Source Control Projects

SonarQube project not updating from Sonar Runner

I've provisioned three projects, two of which update as expected each time Jenkins deploys to the dev environment. However, while the third job populates with the initial results, each subsequent run does not update the project despite successful SonarRunner execution. (I've scrubbed some of the names and paths).
Here is the failing job project file:
# required metadata
sonar.projectKey=xxxxxxx
sonar.projectName=xxxxxxx
sonar.projectVersion=1.0
# path to source directories (required)
sonar.sources=src
# paths to exclude
#sonar.exclusions=
sonar.scm.disabled=true
sonar.javascript.mode=skip
sonar.css.mode=skip
# Encoding of the source code
sonar.sourceEncoding=UTF-8
Here is the console output from Jenkins:
SonarQube Runner 2.4
Java 1.7.0_71 Oracle Corporation (64-bit)
Linux 2.6.32-504.3.3.el6.x86_64 amd64
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: xxxxxxxx/sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: xxxxxxx/workspace/.sonar
INFO: SonarQube Server 5.1
12:29:29.558 INFO - Load global repositories
12:29:29.784 INFO - Load global repositories (done) | time=228ms
12:29:29.786 INFO - Server id: 20150522113240
12:29:29.788 INFO - User cache: /var/lib/jenkins/.sonar/cache
12:29:29.797 INFO - Install plugins
12:29:30.091 INFO - Install JDBC driver
12:29:30.112 INFO - Create JDBC datasource for jdbc:mysql://xxxxxxx/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
12:29:31.619 INFO - Initializing Hibernate
12:29:33.037 INFO - Load project repositories
12:29:34.129 INFO - Load project repositories (done) | time=1092ms
12:29:34.130 INFO - Load project settings
12:29:34.834 INFO - Load technical debt model
12:29:34.863 INFO - Apply project exclusions
12:29:36.001 INFO - ------------- Scan www.XXXXXXXXX.com-XXXXXXXX
12:29:36.005 INFO - Load module settings
12:29:36.214 INFO - Load rules
12:29:37.422 INFO - Base dir: xxxxx/workspace
12:29:37.422 INFO - Working dir: xxxxx.sonar
12:29:37.422 INFO - Source paths: src
12:29:37.423 INFO - Source encoding: UTF-8, default locale: en_US
12:29:37.423 INFO - Index files
12:29:38.342 INFO - 254 files indexed
12:29:43.048 INFO - Quality profile for java: Sonar way
12:29:43.048 INFO - Quality profile for xml: Sonar way
12:29:43.524 WARN - ----------------------------------------------------------------
12:29:43.524 WARN - Sonargraph: Skipping project xxxxx, since no Sonargraph rules are activated in current SonarQube quality profile.
12:29:43.524 WARN - ----------------------------------------------------------------
12:29:43.526 INFO - JIRA issues sensor will not run as some parameters are missing.
12:29:43.541 INFO - Sensor JavaSquidSensor
12:29:44.015 INFO - Java Main Files AST scan...
12:29:44.017 INFO - 238 source files to be analyzed
12:29:55.279 INFO - 238/238 source files analyzed
12:29:55.278 INFO - Java Main Files AST scan done: 11263 ms
12:29:55.279 WARN - Java bytecode has not been made available to the analyzer. The org.sonar.java.bytecode.visitor.DependenciesVisitor#7cd07967, org.sonar.java.checks.UnusedPrivateMethodCheck#43b7ee4b, org.sonar.java.checks.RedundantThrowsDeclarationCheck#607da0a8 are disabled.
12:29:55.280 INFO - Java Test Files AST scan...
12:29:55.280 INFO - 0 source files to be analyzed
12:29:55.280 INFO - Java Test Files AST scan done: 0 ms
12:29:55.280 INFO - 0/0 source files analyzed
12:29:55.466 INFO - Sensor JavaSquidSensor (done) | time=11925ms
12:29:55.467 INFO - Sensor Lines Sensor
12:29:55.501 INFO - Sensor Lines Sensor (done) | time=34ms
12:29:55.501 INFO - Sensor QProfileSensor
12:29:55.505 INFO - Sensor QProfileSensor (done) | time=4ms
12:29:55.506 INFO - Sensor InitialOpenIssuesSensor
12:30:29.395 INFO - Sensor InitialOpenIssuesSensor (done) | time=33889ms
12:30:29.395 INFO - Sensor ProjectLinksSensor
12:30:29.404 INFO - Sensor ProjectLinksSensor (done) | time=9ms
12:30:29.404 INFO - Sensor VersionEventsSensor
12:30:29.427 INFO - Sensor VersionEventsSensor (done) | time=23ms
12:30:29.427 INFO - Sensor XmlSensor
12:31:14.500 INFO - Sensor XmlSensor (done) | time=45073ms
12:31:14.500 INFO - Sensor LineCountSensor
12:31:15.041 INFO - Sensor LineCountSensor (done) | time=541ms
12:31:15.041 INFO - Sensor SurefireSensor
12:31:15.728 INFO - Sensor SurefireSensor (done) | time=687ms
12:31:15.729 INFO - Sensor SCM Sensor
12:31:15.729 INFO - SCM Sensor is disabled
12:31:15.729 INFO - Sensor SCM Sensor (done) | time=0ms
12:31:15.729 INFO - Sensor CPD Sensor
12:31:15.729 INFO - JavaCpdEngine is used for java
12:31:15.731 INFO - Cross-project analysis disabled
12:31:16.474 INFO - DefaultCpdEngine is used for xml
12:31:16.476 INFO - Sensor CPD Sensor (done) | time=747ms
12:31:16.477 INFO - No quality gate is configured.
12:31:16.520 INFO - Compare to previous analysis (2015-05-22)
12:31:16.524 INFO - Compare over 30 days (2015-04-26, analysis of Fri May 22 11:08:22 CDT 2015)
12:31:17.192 INFO - Execute decorators...
12:32:58.147 INFO - Store results in database
12:33:12.805 INFO - Analysis reports generated in 4585ms, dir size=64 MB
12:33:14.429 INFO - Analysis reports compressed in 1624ms, zip size=9 MB
12:33:16.335 INFO - Analysis reports sent to server in 1905ms
12:33:16.336 INFO - ANALYSIS SUCCESSFUL, you can browse xxxxxx
12:33:16.336 INFO - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 3:47.493s
Final Memory: 37M/2167M
I also had some issue last time.
I use community version, so I could not manage the pull request and branch name.
I installed locally, so every time you want to update the code, you must run manually sonar-scanner.bat xxxxx
And new codes menu will update automatically after you run that command.

Sonar runner codenarc sensor ignore violation from Codenarc

I have grails project with CodeNarc Plugin installed and generated xml report. Installed and configured SonarQube with following configurations and versions:
Grails 2.3.7
SonarQube server- 4.5
SonarQube Runner- 2.4
CodeNarc Plugin- 0.22
Sonar-project.properties file contains
#sonar-runner.properties
sonar.projectKey=key
sonar.projectName=Project Name
sonar.projectVersion=1.0
sonar.sources=src, grails-app/services, grails-app/controllers, grails-app/domain
sonar.tests=test/
sonar.language=grvy
sonar.sourceEncoding=UTF-8
sonar.groovy.codenarc.reportPath=target/codenarc/codeNarcXMLReport.xml
Generated CodeNarc XML report and added its report path in file.
Sonar runner analyse project but with zero issues
Sonar runner unable to index resources and throws warning for CodeNarc rules violations.
SonarQube Runner 2.4
Java 1.7.0_21 Oracle Corporation (64-bit)
Linux 3.11.0-26-generic amd64
INFO: Runner configuration file: /media/Others/softwares/sonar-runner-2.4/conf/sonar-runner.properties
INFO: Project configuration file: /media/Others/repo/project/sonar-project.properties
INFO: Default locale: "en_IN", source code encoding: "UTF-8"
INFO: Work directory: /media/Others/repo/project/./.sonar
INFO: SonarQube Server 4.5
11:20:57.146 INFO - Load global referentials...
11:20:57.356 INFO - Load global referentials done: 213 ms
11:20:57.367 INFO - User cache: /home/.sonar/cache
11:20:57.378 INFO - Install plugins
11:20:57.680 INFO - Install JDBC driver
11:20:57.688 INFO - Create JDBC datasource for jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
11:20:59.590 INFO - Initializing Hibernate
11:21:01.310 INFO - Load project referentials...
11:21:02.342 INFO - Load project referentials done: 1032 ms
11:21:02.342 INFO - Load project settings
11:21:03.193 INFO - Loading technical debt model...
11:21:03.218 INFO - Loading technical debt model done: 25 ms
11:21:03.222 INFO - Apply project exclusions
11:21:03.598 INFO - ------------- Scan project
11:21:03.603 INFO - Load module settings
11:21:04.228 INFO - Language is forced to grvy
11:21:04.230 INFO - Loading rules...
11:21:05.224 INFO - Loading rules done: 994 ms
11:21:05.260 INFO - Configure Maven plugins
11:21:05.537 INFO - Compare to previous analysis (2014-12-23)
11:21:05.557 INFO - Compare over 30 days (2014-11-23, analysis of 2014-11-10 17:20:47.0)
11:21:05.578 INFO - Compare to previous version (2014-10-30)
11:21:05.636 INFO - Loaded quality gate 'SonarQube way'
11:21:05.817 INFO - Base dir: /media/Others/repo/project/.
11:21:05.817 INFO - Working dir: /media/Others/repo/project/./.sonar
11:21:05.818 INFO - Source paths: src, grails-app/services, grails-app/controllers, grails-app/domain
11:21:05.818 INFO - Test paths: test
11:21:05.818 INFO - Source encoding: UTF-8, default locale: en_IN
11:21:05.818 INFO - Index files
11:21:06.276 INFO - 226 files indexed
11:21:44.020 INFO - Quality profile for grvy: Sonar way
11:21:44.404 INFO - Sensor QProfileSensor...
11:21:44.416 INFO - Sensor QProfileSensor done: 13 ms
11:21:44.416 INFO - Sensor CodeNarc...
11:21:44.593 WARN - No such rule in Sonar, so violation from CodeNarc will be ignored:
11:21:44.594 WARN - No such rule in Sonar, so violation from CodeNarc will be ignored:
11:21:44.595 WARN - No such rule in Sonar, so violation from CodeNarc will be ignored:
11:21:44.596 WARN - No such rule in Sonar, so violation from CodeNarc will be ignored:
11:21:44.599 WARN - Resource is not indexed. Ignoring violation org.sonar.api.rules.Violation#221
[resource=org.sonar.api.resources.File#4254e18d[key=<null>,deprecatedKey=grails-app/controllers/LoginController.groovy,path=<null>,
dir=grails-app/controllers,filename=LoginController.groovy,language=<null>],rule=Rule[id=427,name=Catch
Exception,key=org.codenarc.rule.exceptions.CatchExceptionRule,configKey=CatchException,plugin=grvy,severity=MINOR,isTemplate=false,status=READY,language=grvy,template=<null>],
message=The type Exception should not be caught,severity=<null>,lineId=93,cost=<null>,createdAt=<null>,switchedOff=false,
checksum=<null>,isNew=false,isManual=false,permanentId=<null>,personId=<null>]
11:21:44.602 WARN - Resource is not indexed. Ignoring violation org.sonar.api.rules.Violation#5e3666d9[resource=org.sonar.api.resources.File#459a60e1[key=<null>,
deprecatedKey=grails-app/controllers/LoginController.groovy,path=<null>,dir=grails-app/controllers,filename=LoginController.groovy,language=<null>],rule=Rule[id=431,name=Unused Method Parameter,key=org.codenarc.rule.unused.UnusedMethodParameterRule,configKey=UnusedMethodParameter,
plugin=grvy,severity=MINOR,isTemplate=false,status=READY,language=grvy,template=<null>],
message=Violation in class LoginController. Method parameter [newSignup] is never referenced in the method authComplete of class LoginController,severity=<null>,lineId=100,cost=<null>,createdAt=<null>,
switchedOff=false,checksum=<null>,isNew=false,isManual=false,permanentId=<null>,personId=<null>]
...
...
...
11:21:45.661 WARN - Resource is not indexed. Ignoring violation org.sonar.api.rules.Violation#6c95883d[resource=org.sonar.api.resources.File#4d23947c[key=<null>,deprecatedKey=test/unit/project/HomeControllerTests.groovy,
path=<null>,dir=test/unit/project,filename=HomeControllerTests.groovy,language=<null>],rule=Rule[id=643,name=Empty Method,key=org.codenarc.rule.basic.EmptyMethodRule,configKey=EmptyMethod,plugin=grvy,
severity=MINOR,isTemplate=false,status=READY,language=grvy,template=<null>],
message=Violation in class HomeControllerTests. The method tearDown is both empty and not marked with #Override,severity=<null>,lineId=121,cost=<null>,createdAt=<null>,switchedOff=false,checksum=<null>,
isNew=false,isManual=false,permanentId=<null>,personId=<null>]
11:21:45.661 INFO - Sensor CodeNarc done: 1245 ms
11:21:45.662 INFO - Sensor GroovySensor...
11:21:48.552 INFO - GMetrics completed: 1493ms
11:21:49.580 INFO - GMetrics completed: 941ms
11:21:51.285 INFO - GMetrics completed: 1601ms
11:21:51.561 INFO - GMetrics completed: 156ms
11:21:52.081 INFO - GMetrics completed: 488ms
11:21:52.167 INFO - Sensor GroovySensor done: 6505 ms
11:21:52.167 INFO - Sensor Groovy CoberturaSensor...
11:21:52.167 INFO - Analyzing Cobertura report: target/test-reports/cobertura/coverage.xml
11:21:52.955 INFO - Sensor Groovy CoberturaSensor done: 788 ms
11:21:52.956 INFO - Sensor ScmActivitySensor...
11:21:52.956 INFO - Trying to guess scm provider from project layout...
11:21:52.956 INFO - Found SCM type: git
11:21:52.958 INFO - Retrieve SCM blame information with encoding UTF-8...
11:21:55.580 INFO - Retrieve SCM blame information with encoding UTF-8 done: 2622 ms
11:21:55.581 INFO - Sensor ScmActivitySensor done: 2625 ms
11:21:55.585 INFO - Sensor InitialOpenIssuesSensor...
11:21:55.597 INFO - Sensor InitialOpenIssuesSensor done: 11 ms
11:21:55.597 INFO - Sensor ProjectLinksSensor...
11:21:55.607 INFO - Sensor ProjectLinksSensor done: 10 ms
11:21:55.608 INFO - Sensor VersionEventsSensor...
11:21:55.733 INFO - Sensor VersionEventsSensor done: 125 ms
11:21:55.733 INFO - Sensor FileHashSensor...
11:21:55.743 INFO - Sensor FileHashSensor done: 9 ms
11:21:55.743 INFO - Sensor CPD Sensor (wrapped)...
11:21:55.743 INFO - DefaultCpdEngine is used for grvy
11:21:55.751 INFO - Cross-project analysis disabled
11:21:56.330 INFO - Sensor CPD Sensor (wrapped) done: 587 ms
11:21:56.918 INFO - Execute decorators...
11:22:01.785 INFO - Store results in database
11:22:10.256 INFO - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/project
11:22:10.392 INFO - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
11:22:10.393 INFO - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
11:22:10.461 INFO - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
11:22:10.473 INFO - -> Keep one snapshot per day between 2014-11-25 and 2014-12-22
11:22:10.475 INFO - -> Keep one snapshot per week between 2013-12-24 and 2014-11-25
11:22:10.475 INFO - -> Keep one snapshot per month between 2009-12-29 and 2013-12-24
11:22:10.476 INFO - -> Delete data prior to: 2009-12-29
11:22:10.482 INFO - -> Clean project [id=225]
11:22:10.487 INFO - <- Clean snapshot 8702
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 1:15.303s
Final Memory: 26M/737M
INFO: ------------------------------------------------------------------------
I have installed all necessary plugins in SonarQube Server
After all configuration why these rules are getting ignored and zero issues generated for project ?
I have the same problem with getting ignored issues generated from codenarc report.
I found similar topic in sonarqube Nabble service that probably removing from codenarc report from path attributes every "grails-app/domain/", "grails-app/services/" etc. will resolve the problem, but this is only the source of the problem, there is nothing about how to do it automatically.
Below I attached the link to this post in the article.
http://sonarqube.15.x6.nabble.com/No-Issues-and-code-coverage-for-groovy-in-multi-language-project-with-SonarQube-4-2-tp5023761p5023806.html
We had this same problem. The issue surrounded SonarQube not being able to process violations in the CodeNarc report XML file. As shared in a previous answer, entries in the XML file that looks like the following:
...
<Package path='grails-app' totalFiles='54' filesWithViolations='46' priority1='10' priority2='92' priority3='610'/>
<Package path='grails-app/controllers' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
<Package path='grails-app/controllers/com' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
<Package path='grails-app/controllers/com/...' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
...
will cause them to be ignored. As a work-around, we wrote a groovy script that strips out the "grails-app" and "grails-app/<folder>/" from the report file so that it looks like the following:
...
<Package path='com' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
<Package path='com/...' totalFiles='16' filesWithViolations='16' priority1='6' priority2='71' priority3='299'/>
...
The script is run during our Jenkins builds after the report is generated and before the Sonar analysis is performed.
We are running SonarQube 4.5.1 (LTS) and using the version 1.0.1 of the Groovy plugin.

Resources