How do I get Checkstyle to ignore final method rule on classes marked with the @Entity annotation?
Say I have classes marked with the @Entity annotation
@Entity
class User {
public String getName(String name) {
return this.name;
}
}
Checkstyle will report that the class is not built for extension and suggest marking the methods with final (or the whole class). I can't do this because it's marked as an 开发者_StackOverflow社区entity which can't be final.
How do I get Checkstyle to ignore classes marked with @Entity for this rule?
Thanks
Look at the SuppressionFilter or SuppressionCommentFilter
Filter SuppressionFilter rejects audit events for Check errors according to a suppressions XML document in a file.
The module you want to disable is DesignForExtension. Just remove it from your configuration file.
Are you using Ant build? If so, in your checkstyle target, try something like:
<checkstyle>
<fileset dir="src.dir">
<include name="**/*.java" />
<exclude name="User.java" />
</fileset>
</checkstyle>
精彩评论