diff --git a/config/suppressions.xml b/config/suppressions.xml index 3c5b2aa07e5..26269f78d2e 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..2a5165c92b1 100644 --- a/src/main/resources/google_checks.xml +++ b/src/main/resources/google_checks.xml @@ -16,7 +16,10 @@ Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov. --> - + + + + @@ -47,6 +50,21 @@ + + + + + + + + + + + + + + + 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 9a42a2add9d..478a39588ab 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java @@ -1539,6 +1539,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 e270af3d6f1..3895cb5ca2c 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..2e6d26bc8fb 100644 --- a/src/xdocs/google_style.xml +++ b/src/xdocs/google_style.xml @@ -2302,10 +2302,19 @@

    It is possible to suppress some violations by embeded filters - SuppressionFilter - and + SuppressionFilter, - SuppressionXpathFilter. + SuppressionXpathFilter, + + SuppressWithNearbyCommentFilter, + + SuppressionCommentFilter + and + + SuppressWarningsFilter + in conjunction with + + SuppressWarningsHolder. Location of config file for SuppressionFilter can be defined by system property org.checkstyle.google.suppressionfilter.config (default value is checkstyle-suppressions.xml). @@ -2313,13 +2322,33 @@ can be defined by system property org.checkstyle.google.suppressionxpathfilter.config (default value is checkstyle-xpath-suppressions.xml). + To suppress a check on a block of code using SuppressWithNearbyCommentFilter + surround the code block with // CHECKSTYLE.OFF: NameOfTheCheck and + // CHECKSTYLE.ON: NameOfTheCheck (replace NameOfTheCheck with the actual + check to be suppressed). + To suppress a check in the next line of code using SuppressionCommentFilter + precede the line of code with // CHECKSTYLE.OFF: NameOfTheCheck (replace + NameOfTheCheck with the actual check to be suppressed). + To suppress a check using SuppressWarningsFilter use Java's + @SuppressWarnings 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 if 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, + + SuppressWarningsHolder.