我继承了一个使用 MyBatis 的代码库。SpotBugs 告诉我,SubjectRepositoryQueries could be refactored into a named _static_ inner class.我从未遇到过这个术语,我希望有人能解释一下它到底要求我做得更好。看起来它SubjectRepositoryQueries实际上是命名的(它不是匿名的),并且它已经是静态的。SubjectRepositoryQueries不能声明为私有,因为它位于接口内部。
@Mapper
public interface SubjectRepositoryService {
@SelectProvider(type = SubjectRepositoryQueries.class, method = "search")
List<Subject> search(SubjectSearch subjectSearch);
static final class SubjectRepositoryQueries {
public String search(final SubjectSearch subjectSearch) {
... some string generation
}
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我一直在努力添加SpotBugs到当前正在处理的android项目中。我设法使其正常运行,但是我对它的设置方式并不感到太兴奋。现在,配置位于我的app / build.gradle文件中,这使文件的管理更简单。
我想知道是否有SpotBugs / Gradle的专家,他知道一种将配置提取到单独文件中的方法。
这是我的app / build.gradle(样板已删除):
buildscript {
repositories {
...
}
dependencies {
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.2.2'
classpath 'io.fabric.tools:gradle:1.25.4'
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
}
}
plugins {
id 'com.gladed.androidgitversion' version '0.4.3'
id "com.github.spotbugs" version "1.6.2"
}
...
apply plugin: 'com.github.spotbugs'
apply from: '../config/quality/quality.gradle'
apply from: '../app/jacoco.gradle'
apply from: '../app/ktlint.gradle'
apply from: '../app/androidgit.gradle'
...
spotbugs {
toolVersion = '3.1.3'
ignoreFailures = false
effort = "min"
// This selects what level of bugs to report: low means low priority issues …Run Code Online (Sandbox Code Playgroud) 我是第一次为Gradle项目配置SpotBugs插件。
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.6'
}
}
apply plugin: 'com.github.spotbugs'
Run Code Online (Sandbox Code Playgroud)
运行时gradle check出现错误Plugin with id 'com.github.spotbugs' not found.我在做什么错?
Gradle版本5.0。
我有一个像这样的多项目 Gradle 设置:
RootProject
|
---- ProjectA
|
---- ProjectB
|
---- ProjectC
Run Code Online (Sandbox Code Playgroud)
我想将 SpotBugs 应用于我的所有项目。
在每个项目中执行以下操作明确有效。
例如,在build.gradleof 中的以下内容ProjectA:
plugins {
id 'com.github.spotbugs' version '1.6.9'
}
spotbugs {
ignoreFailures = true
effort = 'min'
showProgress = true
reportLevel = 'medium'
// Only run spotbugs directly as too slow to run as CI.
// Will still run spotbugs when called like "gradlew spotbugsMain"
sourceSets = []
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true …Run Code Online (Sandbox Code Playgroud) 我还在SpotBugs 问题跟踪器上问了这个问题。
抱歉,仍在使用 FindBugs,但我们的积压工作中有一张升级到 SpotBugs 的票证,据我了解,配置是相同的,我只需要更新groupId,artifactId和version。
这是我的一个片段pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.version}</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<effort>Max</effort>
<threshold>High</threshold>
<xmlOutput>true</xmlOutput>
<failOnError>true</failOnError>
<excludeFilterFile>findbugs-filter.xml</excludeFilterFile>
<skip>false</skip>
<plugins>
<plugin>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
<version>${fb-contrib.version}</version>
</plugin>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>${findsecbugs.version}</version>
</plugin>
</plugins>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我运行以下命令:
mvn verify
Run Code Online (Sandbox Code Playgroud)
这会生成一个文件target/findbugsXML.xml,其中包含BugInstances如下所示的内容:
<BugCollection sequence='0' release='' analysisTimestamp='1554129043559' version='3.0.1' timestamp='1554129041000'>
<BugInstance instanceOccurrenceNum='0' instanceHash='8dc725917956f30f9b8ab828a70d6420' rank='16' abbrev='Bx'
category='PERFORMANCE' priority='1' type='DM_BOXED_PRIMITIVE_TOSTRING' instanceOccurrenceMax='0'>
<ShortMessage>Method allocates a boxed primitive just to …Run Code Online (Sandbox Code Playgroud) 我现在正在使用 FindBugs。我听说 FindBugs 现在已经过时了。SpotBugs 是 FindBugs 的继承者。我想在我的 Jenkins 中安装 SpotBugs 插件。
我在可用插件区域搜索了 SpotBugs,但没有找到任何东西。也没有发现任何线索或 SpotBugs 与 Jenkins 的关系。
我在哪里可以找到 SpotBugs 的 Jenkins 插件,或者还有其他方法吗?
我正在使用具有大量注释的中型 Java 代码库@SuppressFBWarnings。其中一些(并非全部)不再需要,因为代码已变得通用,API 得到改进等。
有没有办法找出不再需要哪些注释?
我可以将它们注释掉并重新运行 SpotBugs,但是手动识别哪些是需要的,哪些不是真的很乏味。所以我希望有一些 SpotBugs 选项,比如+warningTokenEclipse 编译器,或者一些更有想象力的解决方案。
我正在使用 FindBug,我想了解它为文档目的生成的 .XML 报告。
我得到的样本如下。
<BugInstance type="RANGE_ARRAY_INDEX" priority="2" rank="7" abbrev="RANGE" category="CORRECTNESS" first="1">
Run Code Online (Sandbox Code Playgroud)
因此,似乎RANGE_ARRAY_INDEX类别类型CORRECTNESS具有排名,7因此它是scary一个。那么它总是正确的吗?是RANGE_ARRAY_INDEX永远是scary一个?
我找不到任何提及它们之间关系的资源。
我提到了FindBugs Bug Descriptions和FindBugs 2 站点以及这个没有明确答案的问题
好像我们有几个类别,
和
我们有很多类型,因为它在文档中。
谁可以帮我这个事 ?
我正在尝试将 Maven Spotbugs 插件集成到我的项目的 pom.xml 文件中,并使其在运行“mvn site”命令后在“项目报告”部分中生成报告。我能够生成其他报告,例如 PMD、CPD 和 Xref,但 Spotbugs 给我带来了很多麻烦。命令行表明报告已成功配置,但从未生成。我似乎拥有所有必需的依赖项、构建和报告配置。我已经尝试了来自 Spotbugs github 站点、SpotBugs 文档、多个论坛和教程的各种解决方案,但似乎没有任何方法可以解决我的问题。
有人可以给我一个非常详细的步骤,说明如何通过 pom 文件合并 Spotbugs Maven 插件吗?我对 Maven 很陌生,需要一些帮助!如果我需要包含任何文件,也请告诉我。
我在 Eclipse IDE 中使用 Spotbugs 插件。我可以在整个项目上运行 Spotbugs,这给我的印象是该工具需要构建项目才能呈现其分析报告。
但文档说它是一个静态分析工具。
所以,我很好奇如果它需要构建项目,那么我们可以将其称为静态分析工具吗?如果不需要构建项目,我们可以在单个 .java 文件上运行 Spotbugs 吗?