Search code examples
javagradlecheckstyle

Checkstyle off is not working for Checkstyle Gradle


I would like to use //@checkstyle:off and //@checkstyle:on to exempt certain part of the code from being check by checkstyle but it is still complaining.

public void invoke() {
    //@checkstyle:off
    String foo="Don't scan me please";
    //@checkstyle:on
}

Solution

  • https://checkstyle.org/filters/suppressioncommentfilter.html#SuppressionCommentFilter. Please add the module to your checkstyle.xml

    You can add comments to your code to turn off checkstyle (at various levels) and then back on again through the use of comments in your code. E.g.
    //CHECKSTYLE:OFF
    public void someMethod(String arg1, String arg2, String arg3, String arg4) {
    //CHECKSTYLE:ON