-
Notifications
You must be signed in to change notification settings - Fork 54
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
Validation doesn't fail for project with test sources only #454
Comments
Thank you for the detailed information here. This sounds like an easy fix. I will take a look at this as soon as I can.
Sent from my Verizon, Samsung Galaxy smartphone
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: Marvin Rensing ***@***.***>
Sent: Monday, July 18, 2022 9:45:15 AM
To: spotbugs/spotbugs-maven-plugin ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [spotbugs/spotbugs-maven-plugin] Validation doesn't fail for project with test sources only (Issue #454)
Steps to reproduce
* create a new Maven repository with only sources in src/test/..
* there should be no java classes in src/main/
* create a file that violates any Spotbugs rule in src/test/
* add the Spotbugs Maven plugin to the pom.xml file
* set also the plugin's setting includeTests to true (<https://spotbugs.github.io/spotbugs-maven-plugin/verify-mojo.html#includeTests>)
* execute Spotbugs by calling mvn package and mvn spotbugs:check
Observed behavior
No violation detected -> Build green
[INFO] --- spotbugs-maven-plugin:4.7.1.0:spotbugs (spotbugs) @ one-performance-tests ---
[INFO] Fork Value is true
[INFO] Done SpotBugs Analysis....
Expected behavior
Violation is printed and build fails.
Notes
* the when using the option xmlOutput=true the XML file is correctly written and contains violations
* in the class BaseViolationCheckMojo (L490<https://github.com/spotbugs/spotbugs-maven-plugin/blob/760dea77281211cb4b985306a79cfc3105934ff8/src/main/groovy/org/codehaus/mojo/spotbugs/BaseViolationCheckMojo.groovy#L490>) only executes the violation verification if there are class files in the projects output directory (usually target/classes), which is empty for projects only having test sources
* when we add a class like src/main/Test.java to our project, Spotbugs prints the violations and fails the build
—
Reply to this email directly, view it on GitHub<#454>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAHODI7IBAK4CJ2YSXGC6XTVUVNWXANCNFSM534KCRPA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
MetroMarv
pushed a commit
to MetroMarv/spotbugs-maven-plugin
that referenced
this issue
Jul 22, 2022
If you use this plugin in a project that only has test sources (source files in the folder `src/test/`) and no source files in the main folder (`src/main/`), then it'd not validate the report generated by spotbugs. Instead it would only log 0 bugs. Instead of verifying only the folder for class files (main folder), we also check if there are test class files (only if the option `includeTests` is enabled). If there are test files, validation of the report takes place. Fixes spotbugs#454
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
src/test/..
src/main/
src/test/
includeTests
totrue
(includeTests)mvn package
andmvn spotbugs:check
Observed behavior
No violation detected -> Build green
Expected behavior
Violation is printed and build fails.
Notes
xmlOutput=true
the XML file is correctly written and contains violationsBaseViolationCheckMojo
(L490) only executes the violation verification if there are class files in the projects output directory (usuallytarget/classes
), which is empty for projects only having test sourcessrc/main/Test.java
to our project, Spotbugs prints the violations and fails the buildThe text was updated successfully, but these errors were encountered: