java - Checkstyle 'this' 关键字过度使用检测

标签 java checkstyle

是否有 Checkstyle 模块来检测这样的代码

private ServiceClass service = ...

public void someMethod(String param) {
    String result = this.service.find(param);
    if(!this.isValid(result)) {
        throw new RuntimeException();
    } else {
        return result;
    }
} 

private boolean isValid(String param) {
...
}

正如您在这里所看到的,实际上并不需要这个,因为没有任何方法和字段重叠。

RequireThis模块接近我的需求,但看起来它无法检测到这种过度使用。

最佳答案

this isn't needed actually as there are no any method and field overlappings.

没有 Checkstyle 检查来标记不必要的 this 使用。 RequireThis 检查仅识别缺少 this 的区域,而不是相反。

关于java - Checkstyle 'this' 关键字过度使用检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47190730/

相关文章:

java - JLabel 鼠标事件

java - FFmpeg - 过滤器覆盖有一个未连接的输出

java - 如何在 Java 中关闭文件和/或知道我的代码中某个文件被锁定的位置?

java - 让 Eclipse Java Organize Imports 与 Google checkstyle 一起使用

Maven Checkstyle 网站

java - ANT checkstyle 任务 : Can't find/access AST Node

java - 如何使用 Java 套接字读取远程服务器的响应

java - hibernate in子句的限制是什么

xml - Checkstyle 的 PackageHtml-rule 忽略 package-info.java

java - 如何解决 At-clause should have a non-empty description? - 检查样式 - Java