gpt4 book ai didi

gradle - 如何触发DM_CONVERT_CASE

转载 作者:行者123 更新时间:2023-12-03 03:51:28 25 4
gpt4 key购买 nike

我正在处理的代码库对no-arg版本的String#toUpperCase()String#toLowerCase()进行了多次调用。正如在其他地方充分记录的那样,这给使用土耳其语区域设置的人们带来了麻烦。所以我想让FindBugs告诉我何时在我们的代码中使用它。据说FindBugs具有这样的检查(DM_CONVERT_CASE),根据http://findbugs.sourceforge.net/bugDescriptions.html的规定,这应该是3.0.1中的默认检查。但是,即使可以肯定的是,即使现在我们的代码库中确实使用了这些no-arg调用,我也从未见过它的报告。

如何获取FindBugs进行举报?

我使用Gradle为我运行FindBugs:

findbugs {
sourceSets = [ subProject.sourceSets.main, subProject.sourceSets.test ]
ignoreFailures = true
toolVersion = '3.0.1'
}
// exclude generated java sources - by explicitly setting the base source dir
findbugsMain.source = 'src/main/java'

最佳答案

仅当DM_CONVERT_CASE设置为reportLevel时,才会触发low违规。显然,大小写转换在FindBugs中被标记为低优先级错误。

Gradle documentation代表reportLevel:

The priority threshold for reporting bugs. If set to low, all bugs are reported. If set to medium (the default), medium and high priority bugs are reported. If set to high, only high priority bugs are reported.



您需要添加以扩展您的配置:
findbugs {
sourceSets = [ subProject.sourceSets.main, subProject.sourceSets.test ]
ignoreFailures = true
toolVersion = '3.0.1'
reportLevel = 'low'
}
// exclude generated java sources - by explicitly setting the base source dir
findbugsMain.source = 'src/main/java'

您可以在尝试重现该问题的创建的项目 https://github.com/mkordas/DmConvertCase中看到它的工作。

编辑:

对于使用Maven的人,您需要通过以下方式配置 findbugs-maven-plugin:
  <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<threshold>Low</threshold>
</configuration>
</plugin>

关于gradle - 如何触发DM_CONVERT_CASE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29705627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com