gpt4 book ai didi

java - 静态代码分析: method argument is the same constant on all invocations

转载 作者:搜寻专家 更新时间:2023-11-01 03:54:12 24 4
gpt4 key购买 nike

是否有免费的 Java 静态代码分析工具,它可以检测到我在所有方法调用中使用了与方法参数相同的常量值,所以我可以删除参数并在方法体内使用常量值吗?例如。在

class A {
void methodA {
someMethod("first", 42);
}
}

class B {
void methodB {
someMethod("second", 42);
}
void methodC {
someMethod("third", 42);
}
}

我想要报告 someMethod 的第二个参数(假定这 3 个调用是对我项目中该方法的所有调用)。

我在Eclipse编译器警告、Findbugs、CodePro Analytix或UCDetector中都没有发现这样的东西,但我可能错过了相应的设置。

编辑:只是为了确保:我不是在询问如何通过重构删除常量值。我想知道如何检测这种情况,因为这 3 个方法调用可能分布在数千个源文件中。

最佳答案

我想你可以尝试使用 Sonar: http://www.sonarsource.org/

关于java - 静态代码分析: method argument is the same constant on all invocations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13620785/

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