开发者

How to enforce usage of the @Override annotation? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

开发者_高级运维 We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 4 years ago.

Improve this question

Is there a static analysis tool that can enforce usage of the @Override annotation consistently that can be run outside of an IDE? CheckStyle has a MissingOverride check but it only applies to methods that use the @inheritDoc Javadoc tag. I'm looking for a tool that can be run in a new build configuration on a continuous integration machine.


PMD now has a MissingOverride rule.

What about PMD or Findbugs? PMD enables that you can even write your own rule (if it isn't disposable in the default rule set).

https://pmd.github.io/pmd-6.3.0/pmd_userdocs_extending_writing_pmd_rules.html


I am using Sonar wich gives me the warnings but most importantly I am using eclipse (and so does my team) and I have set an option "add missing @Overrides" to be done on save action.


One way is to use TeamCity's "Inspection" runner. I'm not sure if it really qualifies as running outside the IDE since it's configured in IntelliJ and it works by running IntelliJ in headless mode on the TeamCity side.


Error Prone has a MissingOverride Pattern It appears that errorprone is evaluated at compile time. By default this is a warning but I configured it to be an error.


On IntelliJ 2017, go to Settings -> Editor -> Inspections -> Missing @Override annotation

image example 0 (no enough reputation to post images)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜