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

Detected bugs not show in site reports #891

Open
schemacs opened this issue Mar 1, 2019 · 5 comments
Open

Detected bugs not show in site reports #891

schemacs opened this issue Mar 1, 2019 · 5 comments

Comments

@schemacs
Copy link

schemacs commented Mar 1, 2019

No SIC_INNER_SHOULD_BE_STATIC_ANON bugs show in site report(target/site/spotbugs.html), but all three bugs are showed on console by running mvn spotbugs:spotbugs, and also in target/spotbugs.xml。

  • JDK version: openjdk version "1.8.0_65"
  • Spotbugs version: 3.1.11
  • Apache Maven: 3.6.0

image

[INFO] >>> spotbugs-maven-plugin:3.1.11:check (default) > :spotbugs @ xxx >>>
[INFO]
[INFO] --- spotbugs-maven-plugin:3.1.11:spotbugs (spotbugs) @ xxx ---
[INFO] Fork Value is true
     [java] Warnings generated: 3
[INFO] Done SpotBugs Analysis....
[INFO]
[INFO] <<< spotbugs-maven-plugin:3.1.11:check (default) < :spotbugs @ xxx <<<
[INFO]
[INFO]
[INFO] --- spotbugs-maven-plugin:3.1.11:check (default) @ xxx ---
[INFO] BugInstance size is 3
[INFO] Error size is 0
[INFO] Total bugs: 3
[ERROR] The class com.example.CollectTaskService$1 could be refactored into a named _static_ inner class [com.example.CollectTaskService] At CollectTaskService.java:[line 729] SIC_INNER_SHOULD_BE_STATIC_ANON
[ERROR] The class com.example.LogMetaService$1 could be refactored into a named _static_ inner class [com.example.LogMetaService] At LogMetaService.java:[line 435] SIC_INNER_SHOULD_BE_STATIC_ANON
[ERROR] The class com.example.LogMetaService$2 could be refactored into a named _static_ inner class [com.example.LogMetaService] At LogMetaService.java:[line 457] SIC_INNER_SHOULD_BE_STATIC_ANON
[INFO]
<?xml version='1.0' encoding='UTF-8'?>
<BugCollection version='3.1.11' threshold='low' effort='max'><file classname='xxx.CollectTaskService'><BugInstance type='SIC_INNER_SHOULD_BE_STATIC_ANON' priority='Low' category='PERFORMANCE' message='The class xxx.CollectTaskService$1 could be refactored into a named _static_ inner class' lineNumber='729'/></file><file classname='xxx.LogMetaService'><BugInstance type='SIC_INNER_SHOULD_BE_STATIC_ANON' priority='Low' category='PERFORMANCE' message='The class xxx.LogMetaService$1 could be refactored into a named _static_ inner class' lineNumber='435'/><BugInstance type='SIC_INNER_SHOULD_BE_STATIC_ANON' priority='Low' category='PERFORMANCE' message='The class xxx.LogMetaService$2 could be refactored into a named _static_ inner class' lineNumber='457'/></file><Error></Error><Project><SrcDir>xxx/src/main/java</SrcDir><SrcDir>xxx/target/generated-sources/annotations</SrcDir><SrcDir>xxx/src/test/java</SrcDir></Project></BugCollection>
@welcome
Copy link

welcome bot commented Mar 1, 2019

Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.

@schemacs
Copy link
Author

schemacs commented Mar 1, 2019

mcve:

  1. create empty project mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
  2. Add spotbugs to pom.xml
...
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <version>3.1.11</version>
        <configuration>
          <effort>Max</effort>
          <threshold>Low</threshold>
          <xmlOutput>true</xmlOutput>
          <failOnError>false</failOnError>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <version>3.1.11</version>
        <configuration>
          <effort>Max</effort>
          <threshold>Low</threshold>
          <xmlOutput>true</xmlOutput>
          <failOnError>false</failOnError>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
  1. Modify App.java to this:
...
public class App 
{
    Object myFunc(){
        return new Object() {
            @Override
            public String toString(){
                return "Object";
            }
        };
    }
...
}
  1. run mvn package site

You will get

  1. target/spotbugs.xml
<?xml version='1.0' encoding='UTF-8'?>
<BugCollection version='3.1.11' threshold='low' effort='max'><file classname='com.mycompany.app.App'><BugInstance type='SIC_INNER_SHOULD_BE_STATIC_ANON' priority='Low' category='PERFORMANCE' message='The class com.mycompany.app.App$1 could be refactored into a named _static_ inner class' lineNumber='10'/></file><Error></Error><Project><SrcDir>/my-app/src/main/java</SrcDir><SrcDir>/my-app/src/test/java</SrcDir></Project></BugCollection>
  1. target/site/spotbugs.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Generated by Apache Maven Doxia Site Renderer 1.8.1 from com.github.spotbugs:spotbugs-maven-plugin:3.1.11:spotbugs at 2019-03-01 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>my-app &#x2013; SpotBugs Bug Detector Report</title>
    <style type="text/css" media="all">
      @import url("./css/maven-base.css");
      @import url("./css/maven-theme.css");
      @import url("./css/site.css");
    </style>
    <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
    <meta http-equiv="Content-Language" content="en" />
    
  </head>
  <body class="composite">
    <div id="banner">
<div id="bannerLeft">
my-app
</div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="breadcrumbs">
      <div class="xleft">
        <span id="publishDate">Last Published: 2019-03-01</span>
          &nbsp;| <span id="projectVersion">Version: 1.0-SNAPSHOT</span>
      </div>
      <div class="xright"><a href="./" title="my-app">my-app</a>      </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="leftColumn">
      <div id="navcolumn">
       <h5>Project Documentation</h5>
    <ul>
     <li class="collapsed"><a href="project-info.html" title="Project Information">Project Information</a></li>
     <li class="expanded"><a href="project-reports.html" title="Project Reports">Project Reports</a>
      <ul>
       <li class="none"><strong>SpotBugs</strong></li>
      </ul></li>
    </ul>
      <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
        <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
      </a>
      </div>
    </div>
    <div id="bodyColumn">
      <div id="contentBox">
<div class="section">
<h2><a name="SpotBugs_Bug_Detector_Report"></a>SpotBugs Bug Detector Report</h2>
<p>The following document contains the results of <a class="externalLink" href="https://spotbugs.github.io/">SpotBugs</a></p>
<p>SpotBugs Version is <i>3.1.11</i></p>
<p>Threshold is <i>low</i></p>
<p>Effort is <i>max</i></p></div>
<div class="section">
<h2><a name="Summary"></a>Summary</h2>
<table border="0" class="bodyTable">
<tr class="a">
<th>Classes</th>
<th>Bugs</th>
<th>Errors</th>
<th>Missing Classes</th></tr>
<tr class="b">
<td>2</td>
<td>1</td>
<td>0</td>
<td>0</td></tr></table></div>
<div class="section">
<h2><a name="Files"></a>Files</h2>
<table border="0" class="bodyTable">
<tr class="a">
<th>Class</th>
<th>Bugs</th></tr>
<tr class="b">
<td><a href="#com.mycompany.app.App">com.mycompany.app.App</a></td>
<td>1</td></tr></table></div><a name="com.mycompany.app.App"></a>
<div class="section">
<h3><a name="com.mycompany.app.App"></a>com.mycompany.app.App</h3>
<table border="0" class="bodyTable">
<tr class="a">
<th>Bug</th>
<th>Category</th>
<th>Details</th>
<th>Line</th>
<th>Priority</th></tr></table></div>
      </div>
    </div>
    <div class="clear">
      <hr/>
    </div>
    <div id="footer">
      <div class="xright">
        Copyright &#169;      2019.All rights reserved.      </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
  </body>
</html>

image

@schemacs schemacs changed the title SIC_INNER_SHOULD_BE_STATIC_ANON bugs not show in site reports Detected bugs not show in site reports Mar 1, 2019
@schemacs
Copy link
Author

schemacs commented Mar 1, 2019

Maybe this should be moved to spotbugs/spotbugs-maven-plugin? If that is the case, I will close this one, and open a new one there.

@ThrawnCA
Copy link
Contributor

ThrawnCA commented Mar 3, 2019

Possibly. It depends on exactly where the issue is, but if it's specific to the reports generated by the Maven plugin, then that's probably best.

@hazendaz
Copy link
Member

hazendaz commented Jan 5, 2024

@schemacs Just seen this, don't think you opened anything on spotbugs and it was not moved. Is this still occurring on latest?

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

3 participants