racodond / sonar-jproperties-plugin

SonarQube Java Properties Analyzer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues and .properties-File not showing up in SonarQube

StefanKock opened this issue · comments

Hi,

I found this plugin today and I'm now trying to analyse Java Properties files in Maven projects (SonarQube analysis run by Jenkins 2.36 with sonar-maven-plugin).
The problem seems to be, that the file isn't in the scope für analysis. I installed the sonar-jproperties-plugin, restarted SonarQube, configured a quality gate an set it as default. But even when I try to enforce an issue, the issue (duplicate key in file) doesn't show up and neighter the file (MODULE_DIR/src/main/resources/myfile.properties).

Do I miss some config or conventions for/against analysis?

SonarQube: 6.7.3
sonar-jproperties-plugin: 2.6
sonar-maven-plugin: 3.4.0.905

Hi @StefanKock,

Just adding the plugin to SonarQube should be enough.
Could you please provide the full log of the analysis in debug mode?

Thank you

David

Here is the extracted log trimmed to relevant entries:

[INFO] 09:34:59.087 -------------  Scan MODULENAME
[INFO] 09:34:59.093 Base dir: /var/lib/jenkins/workspace/JOBNAME/MODULENAME
[INFO] 09:34:59.093 Working dir: /var/lib/jenkins/workspace/JOBNAME/MODULENAME/target/sonar
[INFO] 09:34:59.093 Source paths: pom.xml, src/main/java
[INFO] 09:34:59.093 Test paths: src/test/java
[INFO] 09:34:59.093 Source encoding: UTF-8, default locale: de_DE
... (Declared extensions of language ...)
[DEBUG] 09:34:59.123 Declared extensions of language Java Properties were converted to sonar.lang.patterns.jproperties : **/*.properties
[DEBUG] 09:34:59.123 Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav

[DEBUG] 09:34:59.127 'pom.xml' indexed with language 'xml'
[DEBUG] 09:34:59.140 'src/main/java/de/.../A.java' indexed with language 'java'
... (indexed with language 'java')

[INFO] 09:34:59.191 342 files indexed
[INFO] 09:34:59.191 0 files ignored because of inclusion/exclusion patterns

[DEBUG] 09:34:59.255 'Java Properties Squid Sensor' skipped because there is no related file in current project

I assume that I have make sure, that the folders src/main/resources/ and src/test/resources/ need to be registered as paths, am I right?

Indeed, only pom.xml and src/main/java are analyzed for now.
You should override sonar.sources=pom.xml,src/main/java,src/main/resources,...

Yeah, your hint is good, but unfortunately not every module has that path (which seems to mandatory if mentioned in sonar.sources arg in root project):

Caused by: org.apache.maven.plugin.MojoExecutionException: 
The directory '/var/lib/jenkins/workspace/PROJECT/OTHER_MODULE/src/main/resources' does not exist for Maven module OTHER_MODULE:war:0.1.0-SNAPSHOT. Please check the property sonar.sources

Do you have any good hint for that problem?

I'd go for a broader configuration: sonar.sources=pom.xml,src or sonar.sources=pom.xml,src/main

Thanks for your quick help. I will have to consider a lot more side effects for the whole analysis (of multiple projects often with modules) before I choose a way to extend the configuration.