Sonar ear exclude - jenkins

Good morning,
I have upgrade my installation of Sonar to the version 4.5.1 and use the latest plugin in Jenkins.
Now when I run a build with Sonar Analysis, Sonar tried to analyse the ear module and generate an error because there is no source in this module.

It is the responsibility of your build to exclude the module. See http://docs.codehaus.org/display/SONAR/Analyzing+with+Maven#AnalyzingwithMaven-ConfiguringtheSonarQubeAnalysis ("Excluding a module from SonarQube" analysis section) for an example with Maven.

Maybe this would help http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus.
Regards.

Related

Sonar 5.2 & Cobertura Plugin doesn't work

We upgraded to Sonar 5.2. But now, the task to process the sonar report fails:
2015.12.21 16:08:20 ERROR [o.s.s.c.t.CeWorkerRunnableImpl] Failed to execute task AVHFFR9SqYJURQAYr8yb
java.lang.IllegalArgumentException: There's no changeset on line 59
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:125) ~[guava-17.0.jar:na]
at org.sonar.server.computation.scm.ScmInfoImpl.getChangesetForLine(ScmInfoImpl.java:64) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.scm.DbScmInfo.getChangesetForLine(DbScmInfo.java:69) ~[sonar-server-5.2.jar:na]
at org.sonar.server.computation.step.NewCoverageMeasuresStep$NewCoverageCounter.initialize(NewCoverageMeasuresStep.java:391) ~[so
If I uninstall the Cobertura Plugin which has version 1.6.3, then the report process works fine. But that's no solution for me because I need these reports. Did anybody succeed to solve this error in another way?
regards
Two thoughts:
1) Your issue seems related to this discussion on SonarQube's group. Check if you have such line number="0" in your cobertura.xml file. Unfortunately the fix is planned for SonarQube 5.4 (i.e. 04/Mar/16.)
2) Depending on your exact needs related to Cobertura reports generation and if you're using Maven, you can try to use QualInsight Maven Cobertura plugin to generate your Cobertura reports. This plugin provides the qualinsight-mojo-cobertura-core mojo, an alternative to the cobertura-maven-plugin mojo you're probably using if your build is Maven based. QualInsight Maven Cobertura plugin generates separate reports for UTs, ITs, and combined Overall Test coverage. It generates standard cobertura.xml reports, but also is able to convert them to SonarQube Generic Test Coverage plugin format.
Maybe generated reports by qualinsight-mojo-cobertura-core won't contain data causing issues + maybe using SonarQube's Generic Coverage plugin instead of SonarQube's Cobertura plugin won't cause the exception you get (it was released 9 days ago and tested towards SQ 5.2, while the Cobertura plugin was last released in September 2014)
If want to give it a try and need help / have questions with this solution, just ask (I'm the developer QualInsight Maven Cobertura plugin.)
Regards,

How to use Checkstyle plugin in Jenkins/Hudson

I am interested to know how to use CheckStyle.
I am doing static code analysis in Hudson, as first part, I installed Static Analyser and CheckStyle plugins in Hudson. But I am not able to find out how to use it in official Hudson checkstyple page also.
official page : http://wiki.hudson-ci.org/display/HUDSON/Checkstyle+Plugin
If you can show me a step by step procedure, that is more helpful to me.
Posting this as an answer per request:
You need to run CheckStyle as part of your build job; Hudson just displays the results from your build. Here is documentation for the Ant task and the Maven plugin.
In the Hudson build job configuration screen you should find a checkbox that turns on Checkstyle. You don't need to change your Maven scripts. I don't know if Ant scripts would need adjustment as we always use Maven.

How do I configure JaCoCo with Sonar

How do I configure JaCoCo with Sonar 2.3 and Maven 3.0.4?
My project is a multi-module Maven project. My top level pom has the following:
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
After running mvn sonar:sonar I am getting 0% Code Coverage reported in Sonar. I should be seeing at least 50%. Note I do see the jacoco.exec in the target folder of each child project.
Consider upgrading Sonar - the current version is 3.2, and has JaCoCo as it's native code coverage module.
Also, see https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/ut for lots of examples
They have modified the GitHub project structure. New link with the examples is:
https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/code-coverage/ut
Hi there are some very interesting articles describing exactly your case. Here's the list
http://www.sonarsource.org/measure-coverage-by-integration-tests-with-sonar-updated/
http://johndobie.blogspot.gr/2011/06/maven-multi-module-with-sonar-and.html
http://johndobie.blogspot.gr/2011/06/seperating-test-code-coverage-with.html
And one relevant question
Jacoco and Sonar code coverage?
Hope you find them useful

How to analyze multi-plugin Eclipse RCP project with existing Ant build using Sonar?

Our Eclipse RCP project contains several plugins and has an existing Ant build using PDE build. I want to add Sonar to our build pipeline. I am aware that Sonar supports analyzing Ant builds in general with the Sonar Ant Task. I am looking for someone who has done this already for a multi-plugin Eclipse RCP application. The Sonar report should look like the report of a multi-module Maven project. Are there any templates/build scripts to copy from available?
Here at SonarSource, we are analysing our Sonar Eclipse Plugins using a combination of Ant and Maven. Maybe this can help you: here are the sources => https://github.com/SonarSource/sonar-eclipse

PMD with grails project

Does PMD works with grails project, i.e. with .groovy files??
i'm using STS editor,
if it works, what setup i have to do?
Please let me know, if anyone have any idea
Thanks in advance
I'm not aware of any PMD plugin for Groovy/Grails. However, there is a CodeNarc Grails plugin, which does similar kinds of static analysis on Groovy/Grails code.
codeNarc is one of the best choices for grails projects, thou it is ignoring java classes that potentially are part of your project.
I have not seen any pmd or findBugs plugins for grails that would take care of the java portion. You can use the STS/Eclipse PMD plugin thou to analyze explicitly the src/java/ folder.
Unfortunately the findBugs eclipse-plugin is not able to limit to a certain parts of the project so it no big use (findBugs works purely on class files and works through the complete project).
I guess it should be possible to write a grails pmd plugin that would analyze the java parts of a grails project.
Starting with Grails 3, the build system uses Gradle. There is a PMD gradle plugin which you could use to perform static analysis on your java source files. There is also a Codenarc gradle plugin which you can use to perform analysis on the groovy files in your project.
https://docs.gradle.org/current/userguide/pmd_plugin.html

Resources