是否有 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/