Skip to content

Validation doesn't fail for project with test sources only #454

@MetroMarv

Description

@MetroMarv

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 (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) 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions