diff --git a/config/suppressions.xml b/config/suppressions.xml index 3c5b2aa07e5..1e1ff016d24 100644 --- a/config/suppressions.xml +++ b/config/suppressions.xml @@ -6,7 +6,7 @@ - + diff --git a/src/main/resources/google_checks.xml b/src/main/resources/google_checks.xml index a24ce515d45..1e28345b417 100644 --- a/src/main/resources/google_checks.xml +++ b/src/main/resources/google_checks.xml @@ -17,6 +17,8 @@ --> + + @@ -363,5 +365,18 @@ default="checkstyle-xpath-suppressions.xml" /> + + + + + + + + + + + + + diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java index dba20df6b1b..5c0c1e30aa7 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java @@ -1541,6 +1541,10 @@ public void testAllStyleRules() throws Exception { styleChecks.remove("SuppressionXpathSingleFilter"); styleChecks.remove("TreeWalker"); styleChecks.remove("Checker"); + styleChecks.remove("SuppressWithNearbyCommentFilter"); + styleChecks.remove("SuppressionCommentFilter"); + styleChecks.remove("SuppressWarningsFilter"); + styleChecks.remove("SuppressWarningsHolder"); assertWithMessage( fileName + " requires the following check(s) to appear: " + styleChecks) diff --git a/src/xdocs/config_annotation.xml b/src/xdocs/config_annotation.xml index 84751844642..72cf40c814e 100644 --- a/src/xdocs/config_annotation.xml +++ b/src/xdocs/config_annotation.xml @@ -1411,6 +1411,10 @@ public void someFunctionWithInvalidStyle() { Checkstyle Style +
  • + + Google Style +
  • diff --git a/src/xdocs/config_filters.xml b/src/xdocs/config_filters.xml index fcf5e677613..6c272afb85c 100644 --- a/src/xdocs/config_filters.xml +++ b/src/xdocs/config_filters.xml @@ -422,6 +422,10 @@ public class UserService { Checkstyle Style +
  • + + Google Style +
  • @@ -1934,6 +1938,10 @@ public static void foo() { Checkstyle Style +
  • + + Google Style +
  • @@ -2209,6 +2217,10 @@ public class UserService { Checkstyle Style +
  • + + Google Style +
  • diff --git a/src/xdocs/google_style.xml b/src/xdocs/google_style.xml index abb72772284..ad695a1b769 100644 --- a/src/xdocs/google_style.xml +++ b/src/xdocs/google_style.xml @@ -2302,24 +2302,65 @@

    It is possible to suppress some violations by embeded filters - SuppressionFilter - and + SuppressionFilter, - SuppressionXpathFilter. - Location of config file for SuppressionFilter can be defined by system property - org.checkstyle.google.suppressionfilter.config (default value is - checkstyle-suppressions.xml). - Location of config file for SuppressionXpathFilter + SuppressionXpathFilter, + + SuppressWithNearbyCommentFilter, + + SuppressionCommentFilter + and + + SuppressWarningsFilter. +

    +

    + Location of config file for + SuppressionFilter can + be defined by system property org.checkstyle.google.suppressionfilter.config + (default value is checkstyle-suppressions.xml). +

    +

    + Location of config file for + SuppressionXpathFilter can be defined by system property org.checkstyle.google.suppressionxpathfilter.config (default value is checkstyle-xpath-suppressions.xml).

    +

    + To suppress a check in the next line of code using + + SuppressWithNearbyCommentFilterprecede the line of code with + // CHECKSTYLE.SUPPRESS: NameOfTheCheck (replace NameOfTheCheck with + the actual check to be suppressed). +

    +

    + To suppress a check on a block of code using + SuppressionCommentFilter + add // CHECKSTYLE.OFF: NameOfTheCheck before the beginning of the code block and + // CHECKSTYLE.ON: NameOfTheCheck after the end of the code block (replace + NameOfTheCheck with the actual check to be suppressed). +

    +

    + To suppress a check using + SuppressWarningsFilter + use Java's@SuppressWarnings({"checkstyle:name_of_the_check", ...}) annotation. + Each value passed in the array parameter must meet the format + checkstyle:name_of_the_check where the checkstyle: is optional and + name_of_the_check is the actual name of check to be suppressed in lowercase + format. +

    For more details please review exact configuration of Filters in google_checks.xml: SuppressionFilter, - SuppressionXpathFilter. + SuppressionXpathFilter + + SuppressWithNearbyCommentFilter, + + SuppressionCommentFilter, + + SuppressWarningsFilter,