Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonar scan fails if there are no class files available #46

Closed
vara-prasad opened this issue Aug 19, 2016 · 14 comments
Closed

Sonar scan fails if there are no class files available #46

vara-prasad opened this issue Aug 19, 2016 · 14 comments
Assignees
Labels
Milestone

Comments

@vara-prasad
Copy link

Sonar scan fails during findbugs execution in the case where there are java source files available and there are no class files available.
In some cases, the class files might be not be available and for this case, findbugs execution should be skipped and should not be failed.
Earlier in sonar-findbugs-plugin-3.2, findbugs execution gets skipped and now we are seeing the exception being raised and sonar scan fails.
Any specific reason on why the behaviour is changed ?
Can we skip the findbugs execution (fallback to old logic) instead of making the scan to fail.

@h3xstream
Copy link
Member

h3xstream commented Aug 19, 2016

Sonar scan fails during findbugs execution in the case where there are java source files available and there are no class files available.

Please give more details about your project. Why are there no class? Are some Java files compiled or none?

This behavior is as design. This is to avoid creating jobs that run Sonar analysis and forgetting about the compilation. It is a safe guard to make sure the plugin is not giving an A+ placebo result.

@pcathm
Copy link

pcathm commented Aug 22, 2016

We also have this problem. We run a standard sonarqube on all jars we create via maven, and have resource only jars. These resource only jars have package-info.java file so that we get some size and code coverage metrics in order that the sonarqube dashboard will show the charts that fail to render if the size and code coverage indications are missing.

This was working quite happily previously and is now broken in 3.4.3, also having the side effect failing the automated builds running on our build server. It may seem like a nice change to make, but the change in behavior means that we have to either special case these jars manually, or revert to the previous version and never update the plugin

EDIT: Just noticed you have already pushed a fix to master. We will just wait for the release.

@vara-prasad
Copy link
Author

@h3xstream
In some cases we will not have compiled classes available for java files. In this case we does not want to fail the sonar analysis and continue with the WARNING message from findbugs.

@rjbrandt
Copy link

We also have this issue, there are times when we want a scan but haven't built the code yet.
I'm unclear as to whether this is going to be fixed in the next release, as it is we have to stay back at V3.3

@h3xstream h3xstream added the bug label Sep 8, 2016
@h3xstream h3xstream added this to the version-3.4.4 milestone Sep 8, 2016
@h3xstream
Copy link
Member

@vara-prasad @rjbrandt As design, if you want to voluntary skip FindBugs analysis explicitly create a profile with no rule. #37

@pcuttle Yup. This edge case should be cover by. #36

I will post an update here when a release package is create.

@vara-prasad
Copy link
Author

@h3xstream We are using multi module project and we use same profile for all the modules.
This happens for one of the sub modules.
The suggestion provided by you is not feasible with project setup we have.
Can we have this as an enhancement to log the message instead of failing the analysis by throwing exception.

@fjakop
Copy link

fjakop commented Sep 19, 2016

We have the same problem as @pcuttle, everything was fine now the modules without java code fail our entire build. We do not consider this an edge case.

@h3xstream h3xstream self-assigned this Sep 23, 2016
@jtognazzi
Copy link

We also have this error with a multi module project.
How can I see the list of module without class file ?

@h3xstream
Copy link
Member

#56 was create to add an optional option to skip the warnings.

@jrobledog
Copy link

jrobledog commented Oct 31, 2016

We are experiencing the same issue with sonarqube 5.6. We have the same profile for all projects and the fact is that our moultimodule project sometimes would not compile but anyway we want to analyse the source code by skipping somehow the bytecode analysis from findbugs.
In previous versions of sonar runner we could use "sonar.excludePlugins" property to skip plugins, but now this property is deprecated and it seems that has no effects on analysis.

@kunfoo
Copy link

kunfoo commented Dec 12, 2017

So what is the name of the option?

@Timunas
Copy link

Timunas commented Dec 15, 2017

I'm having a similar issue with sonar. I tried to get more logging information but using -X flags makes sonar not even parse projects.

I noticed that the project that is making sonar plugin to fail is one that doesn't build any artifact. Could this be the issue?

16:39:36.396 16:39:36.387 INFO  - -------------  Scan awesome-lib
16:39:36.397 16:39:36.394 INFO  - Language is forced to scala
16:39:36.400 16:39:36.395 INFO  - Excluded sources for coverage: 
16:39:36.401 16:39:36.395 INFO  -   **/*Spec.scala
16:39:36.402 16:39:36.398 INFO  - Base dir: /home/jenkins/workspace/
16:39:36.402 16:39:36.398 INFO  - Working dir: /home/jenkins/workspace/
16:39:36.402 16:39:36.398 INFO  - Source paths: src/main/scala
16:39:36.403 16:39:36.399 INFO  - Source encoding: UTF-8, default locale: en_US
16:39:36.405 16:39:36.399 INFO  - Index files
16:39:36.406 16:39:36.399 INFO  - Excluded sources: 
16:39:36.406 16:39:36.399 INFO  -   **/*Spec.scala
16:39:36.406 16:39:36.399 INFO  - Excluded tests: 
16:39:36.406 16:39:36.399 INFO  -   **/*Spec.scala
16:39:36.406 16:39:36.401 INFO  - 1 files indexed
16:39:36.406 16:39:36.401 INFO  - 0 files ignored because of inclusion/exclusion patterns
16:39:36.407 16:39:36.405 INFO  - Quality profile for scala: Awesome
16:39:36.419 16:39:36.416 INFO  - Project is pulse-messaging (pulse-messaging)
16:39:36.425 16:39:36.416 INFO  - Project modules: []
16:39:36.425 16:39:36.416 INFO  - Report [/home/jenkins/workspace/target/jacoco.exec] exists?[false] isFile?[false]
16:39:36.427 16:39:36.416 INFO  - ScalaCoverageSensor: will not executed.
16:39:36.431 16:39:36.416 INFO  - 	foundReport = false
16:39:36.431 16:39:36.416 INFO  - 	hasScala    = true
16:39:36.431 16:39:36.416 INFO  - 	languages are [scala]
16:39:36.431 16:39:36.416 INFO  - ScalaItCoverageSensor: will not executed.
16:39:36.431 16:39:36.416 INFO  - ScalaItCoverageSensor: will not executed.
16:39:36.431 16:39:36.417 INFO  - Scala detected ... will execute ScalaSurefireSensor 
16:39:36.431 16:39:36.417 INFO  - JaCoCoSensor: JaCoCo report not found : /home/jenkins/workspace/target/jacoco.exec
16:39:36.431 16:39:36.417 INFO  - JaCoCoItSensor: JaCoCo IT report not found: /home/jenkins/workspace/target/jacoco-it.exec
16:39:36.431 16:39:36.418 INFO  - Sensor BaseMetricsSensor
16:39:36.431 16:39:36.426 INFO  - Sensor BaseMetricsSensor (done) | time=8ms
16:39:36.431 16:39:36.426 INFO  - Sensor Lines Sensor
16:39:36.431 16:39:36.426 INFO  - Sensor Lines Sensor (done) | time=0ms
16:39:36.432 16:39:36.426 INFO  - Sensor QProfileSensor
16:39:36.432 16:39:36.426 INFO  - Sensor QProfileSensor (done) | time=0ms
16:39:36.432 16:39:36.426 INFO  - Sensor ScoverageSensor
16:39:36.501 INFO: ------------------------------------------------------------------------
16:39:36.545 INFO: EXECUTION FAILURE
16:39:36.547 INFO: ------------------------------------------------------------------------
16:39:36.552 Total time: 9.774s
16:39:36.882 Final Memory: 130M/1299M
16:39:36.882 INFO: ------------------------------------------------------------------------
16:39:36.884 ERROR: Error during Sonar runner execution
16:39:36.885 ERROR: Unable to execute Sonar
16:39:36.891 ERROR: Caused by: None.get
16:39:36.893 ERROR: 
16:39:36.895 ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
16:39:37.015 ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
16:39:37.050 Build step 'Build using sbt' changed build result to FAILURE
16:39:37.184 Build step 'Build using sbt' marked build as failure

@h3xstream
Copy link
Member

#169 was integrated.
Bonus: There is a new configuration #56 to avoid some blocker for complex projects that are not fully compiled yet.

@h3xstream
Copy link
Member

The version 3.7.0 is available in a prerelease form : https://github.com/spotbugs/sonar-findbugs/releases/tag/3.7.0 (SonarQube GG https://groups.google.com/forum/#!topic/sonarqube/2DGGjoMfDSc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants