Halstead metrics with Sonar Qube - metrics

I'm using Sonar Qube and Sonar Runner. How can I calculate Halstead metrics with Sonar Qube? I googled this but couldn't find anything.

Because they're not computed and won't be because we find them irrelevant.

Related

How to exclude symblic execution from SonarQube analysis

During Sonar analysis we have so many exceptions of symbolic execution(Described here). As far as I know the rules responsible for symbolic execution are S2259 S2583 , so I created a quality profile that exclude these rules but still have excetpions during Sonar analysis.
We use sonar-maven-plugin for the analysis and I tested with both sonar 6.5 and sonar 6.7 .
How can I exclude symbolic execution from analysis.
Is your project mapped to use the correct quality profile or is it still pointing to the default profile

Integrated JaCoCo results in SonarQube using Jenkins Maven Multitarget-App

after fighting now with integrating JaCoCo results into my SonarQube to see code coverage for more then one working day, I will try to open another post regarding this topic, because the internet is really messed with postings.
Preconditions:
SonarQube: Version 6.7.2
Maven: 3.5.2
Windows Server2012 R2
I successfully integrated Sonar Scan and results are published. I added the configuration for JaCoCo in the pom.xml of my application and the result files are generated after the build and just using the JaCoCo Jenkins plugin they can be displayed on the Jenkins dashboard. But I did not figure out what Analysis properties the Jenkins action "Execute SonarQube Scanner" needs in order to import the results and display them.
Is "scan" the correct operation or do I need something else to trigger the import?
I saw so many variantes of giving JaCoCo and Sonar the correct parameters, that I do not have a clear picture any more. Any hints maybe looking at my parameters?
As described in the docs, since you're building with Maven you should analyze with it too. There's some global setup you want to do (see the docs) but once that's done, you'll add this to your job instead of your current SonarQube Scanner build step:
$SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL
Note that this needs to come after your build and test execution. The JaCoCo reports should be picked up automatically.
I successfully integrated it now with these Analyses properties and it is working.
sonar.projectName=
sonar.projectKey=
sonar.login =
sonar.password =
sonar.sources=./
sonar.java.binaries=./
sonar.jacoco.reportPaths=./trackingboard-service/target/jacoco.exec
sonar.jacoco.reportMissing.force.zero=true

Where does Sonarqube collects data from?

Last day I was configuring a jenkins job to run sonar on my java project. I had sonar and jacoco plugins configured in my job. Sonar was throwing some error for which my sysadmin asked me to remove the jacoco plugin configuration from job. I removed and now sonar is saying it cannot find cobertura.xml.
So I am curious to know if sonar does analysis on already run jacoco or cobertura task or does it runs its own coverage analysis?
Short answer : In general, coverage is imported to SonarQube by reading a coverage report generated prior to any work of sonarQube.
Longer answer : Historically (read, about two years ago), SonarQube used to try to run coverage tool for java. This was a nightmare to maintain for every use cases and as such it is now up to the developers to provide a coverage report to SonarQube which will only act on those data (linking them to source, compute metrics, display them nicely).
In your case, that means you most probably have the cobertura plugin installed on your SQ instance and it is looking for a report to import.

Modify Sonar overall coverage

I'm pretty new to Sonar, I'm using surefire for the metrics, and I've been just wondering how can I modify the Sonar overall coverage to increase or reduce this value to make it fail my Jenkins job.
Can someone point me in the right direction? I cannot find any documentation so far.
I'm not up to date what with the jenkins integration of sonar. Earlies you could install the build breaker plugin. Depending on your Sonarqube version this will no longer work.
Usually the thresholds for your project are not configured as parameters in the project but within sonarqube. Prior to 4.3 this was done through alerts. Nowadays it's called Quality Gates.
Actually a quite good question. I could not find anything for the maven plugin itself to set up some thresholds.
It seems to be an ongoing discussion.

Can Sonar calculate overall test coverage when using Cobertura?

When using Cobertura I am able to display unit and integration test coverage separately in Sonar however I can't find a way to display the overall test coverage..
The Sonar documentation implies this is possible using Jacoco but I wondered if it was also possible using Cobertura?
Many thanks
It is not possible, at least not with sonarqube 4.3.
You could however, combine unit-test-coverage generated with cobertura with integration-test-coverage generated with jacoco.
The documentation sais clearly:
"If coverage by unit tests is not computed with JaCoCo, overall coverage = integration test coverage."
You can find the documentation here:
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project
Sorry and good luck with yout further configuration!

Resources