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

Setting html to true results in incorrect values in xml #965

Open
soddencarpenter opened this issue Jan 16, 2025 · 0 comments
Open

Setting html to true results in incorrect values in xml #965

soddencarpenter opened this issue Jan 16, 2025 · 0 comments

Comments

@soddencarpenter
Copy link

I apologize if I am misunderstanding how these can be used together.

Start with the following settings in a pom.xml

<plugin>
  <groupId>com.github.spotbugs</groupId>
  <artifactId>spotbugs-maven-plugin</artifactId>
  <version>4.8.6.6</version>
  <configuration>
    <debug>false</debug>
    <effort>Max</effort>
   <threshold>Low</threshold>

    <failOnError>false</failOnError>

    <htmlOutput>false</htmlOutput>
    <xmlOutput>true</xmlOutput>
    <outputDirectory>${project.build.directory}/spotbugs-gen</outputDirectory>
    <xmlOutputDirectory>${project.build.directory}/spotbugs-junk</xmlOutputDirectory>

    <spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs-gen</spotbugsXmlOutputDirectory>
    <spotbugsXmlOutputFilename>${project.artifactId}.xml</spotbugsXmlOutputFilename>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>

In the resulting xml file in the "spotbugs-gen/", the FindBugsSummary will have the correct total_classes (1) and total_size (9):

<FindBugsSummary num_packages="1" total_classes="1" priority_3="1" total_size="9" clock_seconds="1.30" referenced_classes="15" vm_version="17.0.13+11-LTS" total_bugs="1" java_version="17.0.13" gc_seconds="0.00" alloc_mbytes="512.00" cpu_seconds="10.97" peak_mbytes="255.62" timestamp="Thu, 16 Jan 2025 21:14:36 +0000">
  <FileStats path="some/path/badstuff/HeresAClass.java" size="9" bugHash="cb16f806906e6989c3e8fb922aef1152" bugCount="1"/>
  <PackageStats package="gov.sandia.saw.buildtest.badstuff" total_bugs="1" priority_3="1" total_size="9" total_types="1">
    <ClassStats bugs="1" size="9" priority_3="1" interface="false" sourceFile="HeresAClass.java" class="gov.sandia.saw.buildtest.badstuff.HeresAClass"/>
  </PackageStats>
  <FindBugsProfile>
    ...
  </FindBugsProfile>
</FindBugsSummary>

Using the same pom.xml as above, change the <htmlOutput> entry to true. Run the same analysis. The .xml file that is present has incorrect data for the FindBugsSummary, in that:

  • total_classes is now 0
  • total_size is now 0
  • referenced_classes is now 0
<FindBugsSummary num_packages="1" total_classes="0" priority_3="1" total_size="0" clock_seconds="2.40" referenced_classes="0" vm_version="17.0.13+11-LTS" total_bugs="1" java_version="17.0.13" gc_seconds="0.01" alloc_mbytes="512.00" cpu_seconds="13.78" peak_mbytes="301.76" timestamp="Thu, 16 Jan 2025 21:23:46 +0000">
  <FileStats path="some/path/badstuff/HeresAClass.java" size="0" bugHash="cb16f806906e6989c3e8fb922aef1152" bugCount="1"/>
  <FindBugsProfile/>
</FindBugsSummary>

In addition:

  • The <FileStats> attribute size for the class shows 0, whereas previously it showed "9"
  • The <PackageStats> section under the <FindBugsSummary> is missing
  • The <FindBugsProfile> is empty.

Furthermore, running the spotbugs -textui with appropriate parameters from the command line (i.e., not using mvn) generates correct .xml and html.

Expectation:
Turning on htmlOutput should not change the FindBugsSummary entries. It should not remove child sections.

Current Situation:
Setting the <htmlOutput> to true generates different information in the .xml file.

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

No branches or pull requests

1 participant