作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个
public interface Interface0 {
void method0();
}
和一个
public class Implementation0 implements Interface0 {
public void method0() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
我通过声明使用 maven-checkstyle-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>${basedir}/check_style.xml</configLocation>
</configuration>
</plugin>
最后,我在 check_style.xml
中激活了 MissingOverride
:
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="MissingOverride"/>
</module>
</module>
这是我在许多项目中的经验摘录,所有检查工作正常,除了 MissingOverride
没有效果,即没有检测到单个丢失的 @Override
注释。
最佳答案
MissingOverride
模块的文档指出:
Verifies that the java.lang.Override annotation is present when the {@inheritDoc} javadoc tag is present.
换句话说,它不打算检查你想要它检查的内容 - 它只检查 Javadoc 注释中 {@inheritDoc}
标记的使用是否与 配对@Override
注解。
关于java - 如何启用 checkstyle 的 MissingOverride 检查?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50440968/
我有一个 public interface Interface0 { void method0(); } 和一个 public class Implementation0 implements
我是一名优秀的程序员,十分优秀!