Can I somehow ignore any warning for deprecated class?
For example:
I had following warnings AvoidEscapedUnicodeCharacters
, NonEmptyAtclauseDescription
for deprecated class.
How to ignore all of them?
Checkstyle allows you to write your own custom filters . You can use SuppressWarningsFilter
as a basis, because this filter is filtering based on annotations as well. You'd just need to change the annotation that you're looking for.
public class SuppressWarningsFilter
extends AutomaticBean
implements Filter {
@Override
protected void finishLocalSetup() {
// No code by default
}
@Override
public boolean accept(AuditEvent event) {
return !SuppressWarningsHolder.isSuppressed(event);
}
}
Pretty simple, but all of the logic is in SuppressWarningsHolder
. That code is a few hundred lines, but you should be able to copy and paste a lot of it, and probably remove a large chuck as well.
I've implemented this: https://github.com/michaelboyles/checkstyle-annotation-filter . I'll make it available via the central repository at some point.
You just need to add the line below:
@SuppressWarnings("deprecation")
It will ignore all deprecated methods in your code. I hope this will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.