From 8a351b6307105cead858e25c2276644621628a57 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 28 Aug 2023 04:06:24 +0000 Subject: [PATCH 001/833] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 023214e1f6a..0baf0d4450f 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.puppycrawl.tools checkstyle - 10.12.3 + 10.12.4-SNAPSHOT jar checkstyle From 6f58a2a9dd3d648744f09172cb234ccaf3611eae Mon Sep 17 00:00:00 2001 From: Kevin222004 Date: Sat, 26 Aug 2023 22:28:28 +0530 Subject: [PATCH 002/833] Issue #13501: Kill mutation for CommonUtil --- .../pitest-utils-suppressions.xml | 16 ++++++++-------- .../tools/checkstyle/utils/CommonUtil.java | 9 +-------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/config/pitest-suppressions/pitest-utils-suppressions.xml b/config/pitest-suppressions/pitest-utils-suppressions.xml index c060d902075..f32ef69a25f 100644 --- a/config/pitest-suppressions/pitest-utils-suppressions.xml +++ b/config/pitest-suppressions/pitest-utils-suppressions.xml @@ -225,14 +225,14 @@ return stripLeading(strippedCodePoints); - - CommonUtil.java - com.puppycrawl.tools.checkstyle.utils.CommonUtil - baseClassName - org.pitest.mutationtest.engine.gregor.mutators.RemoveConditionalMutator_EQUAL_ELSE - removed conditional - replaced equality check with false - if (index == -1) { - + + + + + + + + diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java b/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java index a3c8429bb85..61042cd00cb 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java @@ -241,15 +241,8 @@ public static boolean isPatternValid(String pattern) { * @return the base class name from a fully qualified name */ public static String baseClassName(String type) { - final String className; final int index = type.lastIndexOf('.'); - if (index == -1) { - className = type; - } - else { - className = type.substring(index + 1); - } - return className; + return type.substring(index + 1); } /** From ad98d097ba2fc068f6f06043352410e88d29f789 Mon Sep 17 00:00:00 2001 From: Kevin222004 Date: Sun, 27 Aug 2023 22:38:39 +0530 Subject: [PATCH 003/833] Issue #13501: Kill mutation for JavaParser --- .../pitest-common-2-suppressions.xml | 16 ++++++++-------- .../tools/checkstyle/JavaParserTest.java | 13 +++++++++++++ .../InputJavaParserHiddenComments4.java | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/javaparser/InputJavaParserHiddenComments4.java diff --git a/config/pitest-suppressions/pitest-common-2-suppressions.xml b/config/pitest-suppressions/pitest-common-2-suppressions.xml index 3945d750166..d01a3a02ad8 100644 --- a/config/pitest-suppressions/pitest-common-2-suppressions.xml +++ b/config/pitest-suppressions/pitest-common-2-suppressions.xml @@ -90,14 +90,14 @@ return text + "[" + getLineNo() + "x" + getColumnNo() + "]"; - - JavaParser.java - com.puppycrawl.tools.checkstyle.JavaParser - appendHiddenCommentNodes - org.pitest.mutationtest.engine.gregor.mutators.returns.NullReturnValsMutator - replaced return value with null for com/puppycrawl/tools/checkstyle/JavaParser::appendHiddenCommentNodes - return root; - + + + + + + + + JavaParser.java diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/JavaParserTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/JavaParserTest.java index dbbd9da862e..f5cad28e5d0 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/JavaParserTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/JavaParserTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; +import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocContentLocationCheck.MSG_JAVADOC_CONTENT_SECOND_LINE; import java.io.File; import java.util.ArrayList; @@ -32,6 +33,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; +import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocContentLocationCheck; import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; public class JavaParserTest extends AbstractModuleTestSupport { @@ -274,6 +276,17 @@ public void testFullJavaIdentifierSupport() throws Exception { .isNotNull(); } + @Test + public void testReturnValueOfAppendHiddenCommentNodes() + throws Exception { + final String[] expected = { + "9:1: " + getCheckMessage(JavadocContentLocationCheck.class, + MSG_JAVADOC_CONTENT_SECOND_LINE), + }; + verifyWithInlineConfigParser( + getPath("InputJavaParserHiddenComments4.java"), expected); + } + private static final class CountComments { private final List lineComments = new ArrayList<>(); private final List blockComments = new ArrayList<>(); diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/javaparser/InputJavaParserHiddenComments4.java b/src/test/resources/com/puppycrawl/tools/checkstyle/javaparser/InputJavaParserHiddenComments4.java new file mode 100644 index 00000000000..32eec94cd76 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/javaparser/InputJavaParserHiddenComments4.java @@ -0,0 +1,14 @@ +/* +com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocContentLocationCheck + + +*/ + +package com.puppycrawl.tools.checkstyle.javaparser; +// violation below 'Javadoc content should start from the next line after /*' +/**Summary. + * + * + */ +public interface InputJavaParserHiddenComments4 { +} From 8f08d58ad552b9d756d164e9f6c11a12c7828a99 Mon Sep 17 00:00:00 2001 From: Kevin222004 Date: Sun, 27 Aug 2023 21:26:55 +0530 Subject: [PATCH 004/833] Issue #13501: Kill mutation for DetailAstImpl-7 --- .../pitest-common-2-suppressions.xml | 16 ++++++++-------- .../tools/checkstyle/DetailAstImplTest.java | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/config/pitest-suppressions/pitest-common-2-suppressions.xml b/config/pitest-suppressions/pitest-common-2-suppressions.xml index d01a3a02ad8..a2198146f4f 100644 --- a/config/pitest-suppressions/pitest-common-2-suppressions.xml +++ b/config/pitest-suppressions/pitest-common-2-suppressions.xml @@ -63,14 +63,14 @@ - - DetailAstImpl.java - com.puppycrawl.tools.checkstyle.DetailAstImpl - removeChildren - org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator - Removed assignment to member variable firstChild - firstChild = null; - + + + + + + + + DetailAstImpl.java diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java index b4e4245c3aa..98594eb4f10 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java @@ -659,6 +659,21 @@ public void testToString() { .isEqualTo("text[0x0]"); } + @Test + public void testRemoveChildren() { + final DetailAstImpl parent = new DetailAstImpl(); + final DetailAstImpl child1 = new DetailAstImpl(); + parent.setFirstChild(child1); + final DetailAstImpl child2 = new DetailAstImpl(); + child1.setNextSibling(child2); + + parent.removeChildren(); + + assertWithMessage("") + .that(parent.getChildCount()) + .isEqualTo(0); + } + private static List getAllFiles(File dir) { final List result = new ArrayList<>(); From 1bb1db653f441bc5ec834c20742438f56f8f204e Mon Sep 17 00:00:00 2001 From: Kevin222004 Date: Sun, 27 Aug 2023 18:36:53 +0530 Subject: [PATCH 005/833] Issue #13501: Kill mutation for DetailAstImpl-6 --- .../pitest-common-2-suppressions.xml | 32 +++++++++---------- .../tools/checkstyle/DetailAstImplTest.java | 6 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/config/pitest-suppressions/pitest-common-2-suppressions.xml b/config/pitest-suppressions/pitest-common-2-suppressions.xml index a2198146f4f..1d11fe1a12d 100644 --- a/config/pitest-suppressions/pitest-common-2-suppressions.xml +++ b/config/pitest-suppressions/pitest-common-2-suppressions.xml @@ -72,23 +72,23 @@ - - DetailAstImpl.java - com.puppycrawl.tools.checkstyle.DetailAstImpl - toString - org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator - removed call to com/puppycrawl/tools/checkstyle/DetailAstImpl::getColumnNo - return text + "[" + getLineNo() + "x" + getColumnNo() + "]"; - - - DetailAstImpl.java - com.puppycrawl.tools.checkstyle.DetailAstImpl - toString - org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator - removed call to com/puppycrawl/tools/checkstyle/DetailAstImpl::getLineNo - return text + "[" + getLineNo() + "x" + getColumnNo() + "]"; - + + + + + + + + + + + + + + + + diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java index 98594eb4f10..257e46d2a12 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java @@ -652,11 +652,11 @@ public void testTreeStructure() throws Exception { public void testToString() { final DetailAstImpl ast = new DetailAstImpl(); ast.setText("text"); - ast.setColumnNo(0); - ast.setLineNo(0); + ast.setColumnNo(1); + ast.setLineNo(1); assertWithMessage("Invalid text") .that(ast.toString()) - .isEqualTo("text[0x0]"); + .isEqualTo("text[1x1]"); } @Test From 7007bef1f43a621757ae0b885818cf8baa0e6ef1 Mon Sep 17 00:00:00 2001 From: Stoyan Kostadinov Date: Sat, 26 Aug 2023 14:51:56 +0200 Subject: [PATCH 006/833] Issue #13100: Create tests from filters xdoc examples --- .../filters/SeverityMatchFilter.java | 10 - .../filters/SuppressWarningsFilter.java | 64 --- .../SuppressWithNearbyCommentFilter.java | 157 ------ .../filters/SuppressWithNearbyTextFilter.java | 202 -------- .../SuppressWithPlainTextCommentFilter.java | 206 -------- .../filters/SuppressionCommentFilter.java | 373 -------------- .../checkstyle/filters/SuppressionFilter.java | 91 ---- .../filters/SuppressionSingleFilter.java | 105 ---- .../filters/SuppressionXpathFilter.java | 311 ------------ .../filters/SuppressionXpathSingleFilter.java | 325 ------------ .../internal/XdocsJavaDocsTest.java | 12 +- .../SeverityMatchFilterExamplesTest.java | 42 ++ .../SuppressWarningsFilterExamplesTest.java | 51 ++ ...ssWithNearbyCommentFilterExamplesTest.java | 105 ++++ ...pressWithNearbyTextFilterExamplesTest.java | 114 +++++ ...ithPlainTextCommentFilterExamplesTest.java | 106 ++++ .../SuppressionCommentFilterExamplesTest.java | 105 ++++ .../SuppressionSingleFilterExamplesTest.java | 123 +++++ ...pressionXpathSingleFilterExamplesTest.java | 159 ++++++ .../filters/severitymatchfilter/Example1.txt | 11 + .../suppressioncommentfilter/Example1.txt | 42 ++ .../suppressioncommentfilter/Example2.txt | 46 ++ .../suppressioncommentfilter/Example3.txt | 48 ++ .../suppressioncommentfilter/Example4.txt | 46 ++ .../suppressioncommentfilter/Example5.txt | 47 ++ .../suppressioncommentfilter/Example6.txt | 52 ++ .../suppressioncommentfilter/Example7.txt | 47 ++ .../suppressioncommentfilter/Example8.txt | 45 ++ .../suppressionsinglefilter/Example1.txt | 20 + .../suppressionsinglefilter/Example10.txt | 10 + .../suppressionsinglefilter/Example2.txt | 11 + .../suppressionsinglefilter/Example3.txt | 11 + .../suppressionsinglefilter/Example4.txt | 11 + .../suppressionsinglefilter/Example5.txt | 11 + .../suppressionsinglefilter/Example6.txt | 11 + .../suppressionsinglefilter/Example7.txt | 12 + .../suppressionsinglefilter/Example8.txt | 11 + .../suppressionsinglefilter/Example9.txt | 11 + .../suppressionxpathsinglefilter/Example1.txt | 28 ++ .../Example10.txt | 23 + .../Example11.txt | 21 + .../Example12.txt | 21 + .../Example13.txt | 25 + .../Example14.txt | 21 + .../suppressionxpathsinglefilter/Example2.txt | 19 + .../suppressionxpathsinglefilter/Example3.txt | 24 + .../suppressionxpathsinglefilter/Example4.txt | 16 + .../suppressionxpathsinglefilter/Example5.txt | 16 + .../suppressionxpathsinglefilter/Example6.txt | 21 + .../suppressionxpathsinglefilter/Example7.txt | 24 + .../suppressionxpathsinglefilter/Example8.txt | 20 + .../suppressionxpathsinglefilter/Example9.txt | 22 + .../suppresswarningsfilter/Example1.txt | 17 + .../suppresswarningsfilter/Example2.txt | 21 + .../Example1.txt | 11 + .../Example2.txt | 15 + .../Example3.txt | 21 + .../Example4.txt | 20 + .../Example5.txt | 18 + .../Example6.txt | 16 + .../Example7.txt | 33 ++ .../Example8.txt | 21 + .../suppresswithnearbytextfilter/Example1.txt | 13 + .../suppresswithnearbytextfilter/Example2.txt | 15 + .../suppresswithnearbytextfilter/Example3.txt | 15 + .../suppresswithnearbytextfilter/Example4.txt | 20 + .../suppresswithnearbytextfilter/Example5.txt | 15 + .../suppresswithnearbytextfilter/Example6.txt | 15 + .../suppresswithnearbytextfilter/Example7.txt | 17 + .../suppresswithnearbytextfilter/Example8.txt | 21 + .../suppresswithnearbytextfilter/Example9.txt | 21 + .../Example1.txt | 8 + .../Example2.txt | 19 + .../Example3.txt | 19 + .../Example4.txt | 23 + .../Example5.txt | 23 + .../Example6.txt | 14 + .../Example7.txt | 40 ++ .../Example8.txt | 22 + src/xdocs/filters/severitymatchfilter.xml | 10 +- .../filters/severitymatchfilter.xml.template | 13 +- .../filters/suppressioncommentfilter.xml | 174 ++++--- .../suppressioncommentfilter.xml.template | 437 ++++------------ src/xdocs/filters/suppressionsinglefilter.xml | 118 +++-- .../suppressionsinglefilter.xml.template | 139 +++--- .../filters/suppressionxpathsinglefilter.xml | 408 +++++++-------- .../suppressionxpathsinglefilter.xml.template | 472 ++++++------------ src/xdocs/filters/suppresswarningsfilter.xml | 26 + .../suppresswarningsfilter.xml.template | 25 +- .../suppresswithnearbycommentfilter.xml | 153 +++--- ...ppresswithnearbycommentfilter.xml.template | 226 ++++----- .../filters/suppresswithnearbytextfilter.xml | 36 +- .../suppresswithnearbytextfilter.xml.template | 269 ++++------ .../suppresswithplaintextcommentfilter.xml | 60 +-- ...esswithplaintextcommentfilter.xml.template | 254 ++++------ 95 files changed, 3324 insertions(+), 3474 deletions(-) create mode 100644 src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterExamplesTest.java create mode 100644 src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilterExamplesTest.java create mode 100644 src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilterExamplesTest.java create mode 100644 src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilterExamplesTest.java create mode 100644 src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilterExamplesTest.java create mode 100644 src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilterExamplesTest.java create mode 100644 src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilterExamplesTest.java create mode 100644 src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilterExamplesTest.java create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/severitymatchfilter/Example1.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example1.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example2.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example3.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example4.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example5.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example6.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example7.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example8.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example1.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example10.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example2.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example3.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example4.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example5.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example6.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example7.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example8.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example9.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example1.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example10.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example11.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example12.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example13.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example14.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example2.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example3.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example4.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example5.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example6.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example7.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example8.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example9.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/Example1.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/Example2.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example1.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example2.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example3.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example4.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example5.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example6.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example7.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example8.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example1.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example2.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example3.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example4.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example5.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example6.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example7.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example8.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example9.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example1.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example2.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example3.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example4.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example5.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example6.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example7.txt create mode 100644 src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example8.txt diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilter.java index ae5170bd969..a2ccd6a0267 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilter.java @@ -49,16 +49,6 @@ * * *

- * For example, the following configuration fragment directs the Checker to not - * report audit events with severity level {@code info}: - *

- *
- * <module name="SeverityMatchFilter">
- *   <property name="severity" value="info"/>
- *   <property name="acceptOnMatch" value="false"/>
- * </module>
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.Checker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilter.java index 5f1fd287c73..ce1cf6451ce 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilter.java @@ -50,70 +50,6 @@ * Checker as parent module. *

*

- * To configure the check that makes tha annotations available to the filter. - *

- *
- * <module name="TreeWalker">
- *               ...
- * <module name="SuppressWarningsHolder" />
- *               ...
- * </module>
- * 
- *

- * To configure filter to suppress audit events for annotations add: - *

- *
- * <module name="SuppressWarningsFilter" />
- * 
- *
- * @SuppressWarnings({"memberName"})
- * private int J; // should NOT fail MemberNameCheck
- *
- * @SuppressWarnings({"MemberName"})
- * @SuppressWarnings({"NoWhitespaceAfter"})
- * private int [] ARRAY; // should NOT fail MemberNameCheck and NoWhitespaceAfterCheck
- * 
- *

- * It is possible to specify an ID of checks, so that it can be leveraged by - * the SuppressWarningsFilter to skip validations. The following examples show how to - * skip validations near code that has {@code @SuppressWarnings("checkstyle:<ID>")} - * or just {@code @SuppressWarnings("<ID>")} annotation, where ID is the ID - * of checks you want to suppress. - *

- *

- * Example of Checkstyle check configuration: - *

- *
- * <module name="RegexpSinglelineJava">
- *   <property name="id" value="systemout"/>
- *   <property name="format" value="^.*System\.(out|err).*$"/>
- *   <property name="message"
- *     value="Don't use System.out/err, use SLF4J instead."/>
- * </module>
- * 
- *

- * To make the annotations available to the filter. - *

- *
- * <module name="TreeWalker">
- *   ...
- *   <module name="SuppressWarningsHolder" />
- *   ...
- * </module>
- * 
- *

- * To configure filter to suppress audit events for annotations add: - *

- *
- * <module name="SuppressWarningsFilter" />
- * 
- *
- * @SuppressWarnings("checkstyle:systemout")
- * public static void foo() {
- *   System.out.println("Debug info."); // should NOT fail RegexpSinglelineJava
- * }
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.Checker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilter.java index b328320667f..b73a107e4e5 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilter.java @@ -98,163 +98,6 @@ * * *

- * To configure a filter to suppress audit events for check on any line - * with a comment {@code SUPPRESS CHECKSTYLE check}: - *

- *
- * <module name="SuppressWithNearbyCommentFilter"/>
- * 
- *
- * private int [] array; // SUPPRESS CHECKSTYLE
- * 
- *

- * To configure a filter to suppress all audit events on any line containing - * the comment {@code CHECKSTYLE IGNORE THIS LINE}: - *

- *
- * <module name="SuppressWithNearbyCommentFilter">
- *   <property name="commentFormat" value="CHECKSTYLE IGNORE THIS LINE"/>
- *   <property name="checkFormat" value=".*"/>
- *   <property name="influenceFormat" value="0"/>
- * </module>
- * 
- *
- * public static final int lowerCaseConstant; // CHECKSTYLE IGNORE THIS LINE
- * 
- *

- * To configure a filter so that {@code // OK to catch (Throwable|Exception|RuntimeException) here} - * permits the current and previous line to avoid generating an IllegalCatch audit event: - *

- *
- * <module name="SuppressWithNearbyCommentFilter">
- *   <property name="commentFormat" value="OK to catch (\w+) here"/>
- *   <property name="checkFormat" value="IllegalCatchCheck"/>
- *   <property name="messageFormat" value="$1"/>
- *   <property name="influenceFormat" value="-1"/>
- * </module>
- * 
- *
- * . . .
- * catch (RuntimeException re) {
- * // OK to catch RuntimeException here
- * }
- * catch (Throwable th) { ... }
- * . . .
- * 
- *

- * To configure a filter so that {@code CHECKSTYLE IGNORE check FOR NEXT - * var LINES} avoids triggering any audits for the given check for - * the current line and the next var lines (for a total of var+1 lines): - *

- *
- * <module name="SuppressWithNearbyCommentFilter">
- *   <property name="commentFormat"
- *       value="CHECKSTYLE IGNORE (\w+) FOR NEXT (\d+) LINES"/>
- *   <property name="checkFormat" value="$1"/>
- *   <property name="influenceFormat" value="$2"/>
- * </module>
- * 
- *
- * static final int lowerCaseConstant; // CHECKSTYLE IGNORE ConstantNameCheck FOR NEXT 3 LINES
- * static final int lowerCaseConstant1;
- * static final int lowerCaseConstant2;
- * static final int lowerCaseConstant3;
- * static final int lowerCaseConstant4; // will warn here
- * 
- *

- * To configure a filter to avoid any audits on code like: - *

- *
- * <module name="SuppressWithNearbyCommentFilter">
- *   <property name="commentFormat"
- *     value="ALLOW (\\w+) ON PREVIOUS LINE"/>
- *   <property name="checkFormat" value="$1"/>
- *   <property name="influenceFormat" value="-1"/>
- * </module>
- * 
- *
- * private int D2;
- * // ALLOW MemberName ON PREVIOUS LINE
- * . . .
- * 
- *

- * To configure a filter to allow suppress one or more Checks (separated by "|") - * and demand comment no less than 14 symbols: - *

- *
- * <module name="SuppressWithNearbyCommentFilter">
- *   <property name="commentFormat"
- *     value="@cs\.suppress \[(\w+(\|\w+)*)\] \w[-\.'`,:;\w ]{14,}"/>
- *   <property name="checkFormat" value="$1"/>
- *   <property name="influenceFormat" value="1"/>
- * </module>
- * 
- *
- * public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfter] A comment here
- * 
- *

- * It is possible to specify an ID of checks, so that it can be leveraged by - * the SuppressWithNearbyCommentFilter to skip validations. The following examples show how to skip - * validations near code that has comment like {@code // @cs-: <ID/> (reason)}, - * where ID is the ID of checks you want to suppress. - *

- *

- * Examples of Checkstyle checks configuration: - *

- *
- * <module name="RegexpSinglelineJava">
- *   <property name="id" value="ignore"/>
- *   <property name="format" value="^.*@Ignore\s*$"/>
- *   <property name="message" value="@Ignore should have a reason."/>
- * </module>
- *
- * <module name="RegexpSinglelineJava">
- *   <property name="id" value="systemout"/>
- *   <property name="format" value="^.*System\.(out|err).*$"/>
- *   <property name="message" value="Don't use System.out/err, use SLF4J instead."/>
- * </module>
- * 
- *

- * Example of SuppressWithNearbyCommentFilter configuration (idFormat which is set to - * '$1' points that ID of the checks is in the first group of commentFormat regular expressions): - *

- *
- * <module name="SuppressWithNearbyCommentFilter">
- *   <property name="commentFormat" value="@cs-: (\w+) \(.*\)"/>
- *   <property name="idFormat" value="$1"/>
- *   <property name="influenceFormat" value="0"/>
- * </module>
- * 
- *
- * @Ignore // @cs-: ignore (test has not been implemented yet)
- * @Test
- * public void testMethod() { }
- *
- * public static void foo() {
- *   System.out.println("Debug info."); // @cs-: systemout (should not fail RegexpSinglelineJava)
- * }
- * 
- *

- * Example of how to configure the check to suppress more than one checks. - * The influence format is specified in the second regexp group. - *

- *
- * <module name="SuppressWithNearbyCommentFilter">
- *   <property name="commentFormat" value="@cs-\: ([\w\|]+) influence (\d+)"/>
- *   <property name="checkFormat" value="$1"/>
- *   <property name="influenceFormat" value="$2"/>
- * </module>
- * 
- *
- * // @cs-: ClassDataAbstractionCoupling influence 2
- * // @cs-: MagicNumber influence 4
- * @Service // no violations from ClassDataAbstractionCoupling here
- * @Transactional
- * public class UserService {
- *   private int value = 10022; // no violations from MagicNumber here
- * }
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilter.java index 8c48da78992..de31d61b1d2 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilter.java @@ -83,208 +83,6 @@ * * *

- * To configure the filter to suppress audit events on the same line: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter"/>
- *   <module name="TreeWalker">
- *     <module name="MagicNumber"/>
- *   </module>
- * </module>
- * 
- *

- * Example: - *

- *
- * int hoursInDay = 24; // SUPPRESS CHECKSTYLE because it is too obvious
- * int daysInWeek = 7; // violation
- * 
- *

- * To configure the filter to suppress audit events on any line that contains - * {@code DO NOT CHECK THIS LINE}: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter">
- *     <property name="nearbyTextPattern" value="DO NOT CHECK THIS LINE"/>
- *   </module>
- *   <module name="TreeWalker">
- *     <module name="MagicNumber"/>
- *   </module>
- * </module>
- * 
- *

- * Example: - *

- *
- * int a = 42; // DO NOT CHECK THIS LINE
- * int b = 43; // violation
- * 
- *

- * To configure the filter to suppress audit events whose check message contains - * the word {@code Line}. In this case, {@code LineLengthCheck}'s violation message - * contains it: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter">
- *     <property name="messagePattern" value=".*Line.*"/>
- *     <property name="nearbyTextPattern" value=".*"/>
- *   </module>
- *   <module name="LineLength">
- *     <property name="max" value="10"/>
- *   </module>
- * </module>
- * 
- *

- * Example: - *

- *
- * export FOO=BAR # ok, because violation message is matching suppress pattern
- * 
- *

- * To configure the filter to suppress audit events only on a check whose id is - * {@code ignoreMe}: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter">
- *     <property name="idPattern" value="ignoreMe"/>
- *   </module>
- *   <module name="LineLength">
- *     <property name="max" value="55"/>
- *   </module>
- *   <module name="TreeWalker">
- *     <module name="MagicNumber">
- *       <property name="id" value="ignoreMe"/>
- *     </module>
- *   </module>
- * </module>
- * 
- *

- * Example: - *

- *
- * int a = 42; // SUPPRESS CHECKSTYLE because i want to
- * static final int LONG_VAR_NAME_TO_TAKE_MORE_THAN_55_CHARS = 22; // LineLength violation
- * 
- *

- * To configure the filter to suppress audit events for the current and next 2 lines: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter">
- *     <property name="lineRange" value="2"/>
- *   </module>
- *   <module name="UniqueProperties"/>
- * </module>
- * 
- *

- * Example: - *

- *
- * key.one=41 # SUPPRESS CHECKSTYLE because I want to
- * key.one=42 # ok
- * key.one=43 # ok
- * key.one=44 # violation
- * 
- *

- * To configure the filter to suppress audit events for the current and previous line: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter">
- *     <property name="lineRange" value="-1"/>
- *   </module>
- *   <module name="UniqueProperties"/>
- * </module>
- * 
- *

- * Example: - *

- *
- * key.one=41 # violation
- * key.one=42 # ok
- * key.one=43 # SUPPRESS CHECKSTYLE because I want to
- * key.one=44 # violation
- * 
- *

- * To configure the filter with a more compact {@code nearbyTextPattern} - * to accept variable {@code checkPattern}: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter">
- *     <property name="nearbyTextPattern"
- *       value="-@cs\[(\w+)\] (\w+)"/>
- *     <property name="checkPattern" value="$1"/>
- *   </module>
- *   <module name="TreeWalker">
- *     <module name="MagicNumber"/>
- *   </module>
- * </module>
- * 
- *

- * Example: - *

- *
- * int a = 42; // -@cs[MagicNumber] We do not consider this number as magic for some reason.
- * int b = 43; // violation
- * 
- *

- * To configure the filter to accept variable {@code checkPattern} and {@code lineRange}: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter">
- *     <property name="nearbyTextPattern"
- *       value="@cs-: (\w+) for ([+-]\d+) lines"/>
- *     <property name="checkPattern" value="$1"/>
- *     <property name="lineRange" value="$2"/>
- *   </module>
- *   <module name="TreeWalker">
- *     <module name="MagicNumber"/>
- *   </module>
- * </module>
- * 
- *

- * Example: - *

- *
- * int a = 42; // @cs-: MagicNumber for +3 lines
- * int b = 43;
- * int c = 44;
- * int d = 45;
- * int e = 46; // violation
- * 
- *

- * To configure the filter to suppress {@code LineLength} violations for lines containing a URL: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithNearbyTextFilter">
- *     <property name="checkPattern" value="LineLength"/>
- *     <property name="nearbyTextPattern"
- *       value="&lt;a href=&quot;[^&quot;]+&quot;&gt;"/>
- *   </module>
- *   <module name="LineLength">
- *     <property name="max" value="90"/>
- *   </module>
- * </module>
- * 
- *

- * Example: - *

- *
- * /**
- *  * Flag description.
- *  *
- *  * Disabled until <a href="www.github.com/owner/repo/issue/9#comment"> // ok
- *  */
- * public static final boolean SOME_FLAG = false;
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.Checker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilter.java index 079b98a9fdd..f1be4af3fba 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilter.java @@ -105,212 +105,6 @@ * * *

- * To configure a filter to suppress audit events between a comment containing - * {@code CHECKSTYLE:OFF} and a comment containing {@code CHECKSTYLE:ON}: - *

- *
- * <module name="Checker">
- *   ...
- *   <module name="SuppressWithPlainTextCommentFilter"/>
- *   ...
- * </module>
- * 
- *

- * To configure a filter to suppress audit events between a comment containing - * line {@code BEGIN GENERATED CONTENT} and a comment containing line - * {@code END GENERATED CONTENT}(Checker is configured to check only properties files): - *

- *
- * <module name="Checker">
- *   <property name="fileExtensions" value="properties"/>
- *
- *   <module name="SuppressWithPlainTextCommentFilter">
- *     <property name="offCommentFormat" value="BEGIN GENERATED CONTENT"/>
- *     <property name="onCommentFormat" value="END GENERATED CONTENT"/>
- *   </module>
- *
- * </module>
- * 
- *
- * //BEGIN GENERATED CONTENT
- * my.property=value1 // No violation events will be reported
- * my.property=value2 // No violation events will be reported
- * //END GENERATED CONTENT
- * . . .
- * 
- *

- * To configure a filter so that {@code -- stop tab check} and {@code -- resume tab check} - * marks allowed tab positions (Checker is configured to check only sql files): - *

- *
- * <module name="Checker">
- *   <property name="fileExtensions" value="sql"/>
- *
- *   <module name="SuppressWithPlainTextCommentFilter">
- *     <property name="offCommentFormat" value="stop tab check"/>
- *     <property name="onCommentFormat" value="resume tab check"/>
- *     <property name="checkFormat" value="FileTabCharacterCheck"/>
- *   </module>
- *
- * </module>
- * 
- *
- * -- stop tab check
- *   SELECT * FROM users // won't warn here if there is a tab character on line
- * -- resume tab check
- *   SELECT 1 // will warn here if there is a tab character on line
- * 
- *

- * To configure a filter so that name of suppressed check mentioned in comment - * {@code CSOFF: regexp} and {@code CSON: regexp} mark a matching - * check (Checker is configured to check only xml files): - *

- *
- * <module name="Checker">
- *   <property name="fileExtensions" value="xml"/>
- *
- *   <module name="SuppressWithPlainTextCommentFilter">
- *     <property name="offCommentFormat" value="CSOFF\: ([\w\|]+)"/>
- *     <property name="onCommentFormat" value="CSON\: ([\w\|]+)"/>
- *     <property name="checkFormat" value="$1"/>
- *   </module>
- *
- * </module>
- * 
- *
- * // CSOFF: RegexpSinglelineCheck
- *  // RegexpSingleline check won't warn any lines below here if the line matches regexp
- * <condition property="checkstyle.ant.skip">
- *   <isset property="checkstyle.ant.skip"/>
- * </condition>
- * // CSON: RegexpSinglelineCheck
- * // RegexpSingleline check will warn below here if the line matches regexp
- * <property name="checkstyle.pattern.todo" value="NOTHingWillMatCH_-"/>
- * 
- *

- * To configure a filter to suppress all audit events between a comment containing - * {@code CHECKSTYLE_OFF: ALMOST_ALL} and a comment containing {@code CHECKSTYLE_OFF: ALMOST_ALL} - * except for the EqualsHashCode check (Checker is configured to check only java files): - *

- *
- * <module name="Checker">
- *   <property name="fileExtensions" value="java"/>
- *
- *   <module name="SuppressWithPlainTextCommentFilter">
- *     <property name="offCommentFormat"
- *       value="CHECKSTYLE_OFF: ALMOST_ALL"/>
- *     <property name="onCommentFormat"
- *       value="CHECKSTYLE_ON: ALMOST_ALL"/>
- *     <property name="checkFormat"
- *       value="^((?!(FileTabCharacterCheck)).)*$"/>
- *   </module>
- *
- * </module>
- * 
- *
- * // CHECKSTYLE_OFF: ALMOST_ALL
- * public static final int array [];
- * private String [] strArray;
- * // CHECKSTYLE_ON: ALMOST_ALL
- * private int array1 [];
- * 
- *

- * To configure a filter to suppress Check's violation message which matches - * specified message in messageFormat(so suppression will not be only by - * Check's name, but also by message text, as the same Check can report violations - * with different message format) between a comment containing {@code stop} and - * comment containing {@code resume}: - *

- *
- * <module name="Checker">
- *   <module name="SuppressWithPlainTextCommentFilter">
- *     <property name="offCommentFormat" value="stop"/>
- *     <property name="onCommentFormat" value="resume"/>
- *     <property name="checkFormat" value="FileTabCharacterCheck"/>
- *     <property name="messageFormat"
- *         value="^File contains tab characters (this is the first instance)\.$"/>
- *   </module>
- * </module>
- * 
- *

- * It is possible to specify an ID of checks, so that it can be leveraged by the - * SuppressWithPlainTextCommentFilter to skip validations. The following examples - * show how to skip validations near code that is surrounded with - * {@code -- CSOFF <ID> (reason)} and {@code -- CSON <ID>}, - * where ID is the ID of checks you want to suppress. - *

- *

- * Examples of Checkstyle checks configuration: - *

- *
- * <module name="RegexpSinglelineJava">
- *   <property name="id" value="count"/>
- *   <property name="format" value="^.*COUNT(*).*$"/>
- *   <property name="message"
- *     value="Don't use COUNT(*), use COUNT(1) instead."/>
- * </module>
- *
- * <module name="RegexpSinglelineJava">
- *   <property name="id" value="join"/>
- *   <property name="format" value="^.*JOIN\s.+\s(ON|USING)$"/>
- *   <property name="message"
- *     value="Don't use JOIN, use sub-select instead."/>
- * </module>
- * 
- *

- * Example of SuppressWithPlainTextCommentFilter configuration (checkFormat which - * is set to '$1' points that ID of the checks is in the first group of offCommentFormat - * and onCommentFormat regular expressions): - *

- *
- * <module name="Checker">
- *   <property name="fileExtensions" value="sql"/>
- *
- *   <module name="SuppressWithPlainTextCommentFilter">
- *     <property name="offCommentFormat" value="CSOFF (\w+) \(\w+\)"/>
- *     <property name="onCommentFormat" value="CSON (\w+)"/>
- *     <property name="idFormat" value="$1"/>
- *   </module>
- *
- * </module>
- * 
- *
- * -- CSOFF join (it is ok to use join here for performance reasons)
- * SELECT name, job_name
- * FROM users AS u
- * JOIN jobs AS j ON u.job_id = j.id
- * -- CSON join
- *
- * -- CSOFF count (test query execution plan)
- * EXPLAIN SELECT COUNT(*) FROM restaurants
- * -- CSON count
- * 
- *

- * Example of how to configure the check to suppress more than one check - * (Checker is configured to check only sql files). - *

- *
- * <module name="Checker">
- *   <property name="fileExtensions" value="sql"/>
- *
- *   <module name="SuppressWithPlainTextCommentFilter">
- *     <property name="offCommentFormat" value="@cs-\: ([\w\|]+)"/>
- *     <property name="checkFormat" value="$1"/>
- *   </module>
- *
- * </module>
- * 
- *
- * -- @cs-: RegexpSinglelineCheck
- * -- @cs-: FileTabCharacterCheck
- * CREATE TABLE STATION (
- *   ID INTEGER PRIMARY KEY,
- *   CITY CHAR(20),
- *   STATE CHAR(2),
- *   LAT_N REAL,
- *   LONG_W REAL);
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.Checker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java index 8e23b8e2397..0b09e43dd31 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java @@ -109,379 +109,6 @@ * * *

- * To configure a filter to suppress audit events (MemberNameCheck, - * ConstantNameCheck and IllegalCatchCheck have been taken here for reference) - * between a comment containing {@code CHECKSTYLE:OFF} and a comment - * containing {@code CHECKSTYLE:ON}: - *

- *
- *   <module name="SuppressionCommentFilter"/>
- *   <module name="MemberName"/>
- *   <module name="ConstantName"/>
- *   <module name="IllegalCatch"/>
- * 
- *
- * class InputSuppressionCommentFilter
- * {
- *  int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- *  //CHECKSTYLE:OFF
- *  int VAR2; // suppressed violation
- *  //CHECKSTYLE:ON
- *
- *  public static final int var3;
- *  // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- *  //CHECKSTYLE:OFF
- *  public static final int var4; // suppressed violation
- *  //CHECKSTYLE:ON
- *
- *  public void method1()
- *  {
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- *    //CHECKSTYLE:OFF
- *
- *    try {}
- *    catch(Exception ex) {} // suppressed violation
- *    catch(Error err) {} // suppressed violation
- *
- *    //CHECKSTYLE:ON
- *  }
- * }
- * 
- *

- * To configure a filter so that {@code // stop constant check} and - * {@code // resume constant check} marks legitimate constant names: - *

- *
- * <module name="SuppressionCommentFilter">
- *   <property name="offCommentFormat" value="stop constant check"/>
- *   <property name="onCommentFormat" value="resume constant check"/>
- *   <property name="checkFormat" value="ConstantNameCheck"/>
- * </module>
- * <module name="MemberName"/>
- * <module name="ConstantName"/>
- * <module name="IllegalCatch"/>
- * 
- *
- * class InputSuppressionCommentFilter
- * {
- *  int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- *  //stop constant check
- *  int VAR2; // violation , Name 'VAR2' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *  //resume constant check
- *
- *  public static final int var3;
- *  // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- *  //stop constant check
- *  public static final int var4; // suppressed violation
- *  //resume constant check
- *
- *  public void method1()
- *  {
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- *    //stop constant check
- *
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *    catch(Error err) {} // violation , Catching 'Error' is not allowed
- *
- *    //resume constant check
- *  }
- * }
- * 
- *

- * To configure a filter so that {@code UNUSED OFF: var} and - * {@code UNUSED ON: var} marks a variable or parameter known not to be - * used by the code by matching the variable name in the message through a - * specified message in messageFormat: - *

- *
- * <module name="SuppressionCommentFilter">
- *   <property name="offCommentFormat" value="ILLEGAL OFF\: (\w+)"/>
- *   <property name="onCommentFormat" value="ILLEGAL ON\: (\w+)"/>
- *   <property name="checkFormat" value="IllegalCatch"/>
- *   <property name="messageFormat" value="^Catching '$1' is not allowed.$"/>
- * </module>
- * <module name="MemberName"/>
- * <module name="ConstantName"/>
- * <module name="IllegalCatch"/>
- * 
- *
- * class InputSuppressionCommentFilter
- * {
- *  int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- *  //ILLEGAL OFF: Exception
- *  int VAR2; // violation , Name 'VAR2' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *  //ILLEGAL ON: Exception
- *
- *  public static final int var3;
- *  // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- *  //ILLEGAL OFF: Exception
- *  public static final int var4;
- *  // violation above ,  Name 'var4' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *  //ILLEGAL ON: Exception
- *
- *  public void method1()
- *  {
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- *    //ILLEGAL OFF: Exception
- *
- *    try {}
- *    catch(Exception ex) {} // suppressed violation
- *    catch(Error err) {} // violation , Catching 'Error' is not allowed
- *
- *    //ILLEGAL ON: Exception
- *  }
- * }
- * 
- *

- * To configure a filter so that name of suppressed check mentioned in comment - * {@code CSOFF: regexp} and {@code CSON: regexp} mark a matching check: - *

- *
- * <module name="SuppressionCommentFilter">
- *   <property name="offCommentFormat" value="CSOFF\: ([\w\|]+)"/>
- *   <property name="onCommentFormat" value="CSON\: ([\w\|]+)"/>
- *   <property name="checkFormat" value="$1"/>
- * </module>
- * <module name="MemberName"/>
- * <module name="ConstantName"/>
- * <module name="IllegalCatch"/>
- * 
- *
- * class InputSuppressionCommentFilter
- * {
- *  int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- *  //CSOFF: MemberName
- *  int VAR2; // suppressed violation
- *  //CSON: MemberName
- *
- *  public static final int var3;
- *  // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- *  //CSOFF: ConstantName
- *  public static final int var4; // suppressed violation
- *  //CSON: ConstantName
- *
- *  public void method1()
- *  {
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- *    //CSOFF: IllegalCatch
- *
- *    try {}
- *    catch(Exception ex) {} // suppressed violation
- *    catch(Error err) {} // suppressed violation
- *
- *    //CSON: IllegalCatch
- *  }
- * }
- * 
- *

- * To configure a filter to suppress all audit events between a comment containing - * {@code CHECKSTYLE_OFF: ALMOST_ALL} and a comment containing - * {@code CHECKSTYLE_OFF: ALMOST_ALL} except for the ConstantName check: - *

- *
- * <module name="SuppressionCommentFilter">
- *   <property name="offCommentFormat" value="CHECKSTYLE_OFF: ALMOST_ALL"/>
- *   <property name="onCommentFormat" value="CHECKSTYLE_ON: ALMOST_ALL"/>
- *   <property name="checkFormat" value="^((?!(ConstantName)).)*$"/>
- * </module>
- * <module name="MemberName"/>
- * <module name="ConstantName"/>
- * <module name="IllegalCatch"/>
- * 
- *
- * class InputSuppressionCommentFilter
- * {
- *  int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- *  //CHECKSTYLE_OFF: ALMOST_ALL
- *  int VAR2; // suppressed violation
- *  //CHECKSTYLE_ON: ALMOST_ALL
- *
- *  public static final int var3;
- *  // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- *  //CHECKSTYLE_OFF: ALMOST_ALL
- *  public static final int var4;
- *  // violation above , Name 'var4' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *  //CHECKSTYLE_ON: ALMOST_ALL
- *
- *  public void method1()
- *  {
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- *    //CHECKSTYLE_OFF: ALMOST_ALL
- *
- *    try {}
- *    catch(Exception ex) {} // suppressed violation
- *    catch(Error err) {} // suppressed violation
- *
- *    //CHECKSTYLE_ON: ALMOST_ALL
- *  }
- * }
- * 
- *

- * It is possible to specify an ID of checks, so that it can be leveraged by the - * SuppressionCommentFilter to skip validations. The following examples show how - * to skip validations near code that is surrounded with {@code // CSOFF <ID>} - * and {@code // CSON <ID>}, where ID is the ID of checks you want to suppress. - * In the config of SuppressionCommentFilter, checkFormat is set to '$1' which points - * to the ID written in the offCommentFormat and onCommentFormat. Config for such a - * case is written below: - *

- *
- * <module name="SuppressionCommentFilter">
- *   <property name="offCommentFormat" value="CSOFF (\w+)"/>
- *   <property name="onCommentFormat" value="CSON (\w+)"/>
- *   <property name="idFormat" value="$1"/>
- * </module>
- * <module name="MemberName">
- *   <property name="id" value="MemberID"/>
- * </module>
- * <module name="ConstantName">
- *   <property name="id" value="ConstantID"/>
- * </module>
- * <module name="IllegalCatch">
- *   <property name="id" value="IllegalID"/>
- * </module>
- * 
- *
- * class InputSuppressionCommentFilter
- * {
- *  int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- *  //CSOFF MemberID
- *  int VAR2; // suppressed violation
- *  //CSON: MemberID
- *
- *  public static final int var3;
- *  // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- *  //CSOFF ConstantID
- *  public static final int var4; // suppressed violation
- *  //CSON ConstantID
- *
- *  public void method1()
- *  {
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- *    //CSOFF IllegalID
- *
- *    try {}
- *    catch(Exception ex) {} // suppressed violation
- *    catch(Error err) {} // suppressed violation
- *
- *    //CSON IllegalID
- *  }
- * }
- * 
- *

- * Example of how to configure the check to suppress checks by name defined in comment. - *

- *
- * <module name="SuppressionCommentFilter">
- *   <property name="offCommentFormat" value="csoff (\w+)"/>
- *   <property name="onCommentFormat" value="cson (\w+)"/>
- *   <property name="checkFormat" value="$1"/>
- * </module>
- *   <module name="MemberName"/>
- *   <module name="ConstantName"/>
- *   <module name="IllegalCatch"/>
- * 
- *
- * class InputSuppressionCommentFilter
- * {
- *  int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- *  //csoff MemberName
- *  int VAR2; // suppressed violation
- *  //cson MemberName
- *
- *  public static final int var3;
- *  // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- *  //csoff ConstantName
- *  //csoff IllegalCatch
- *
- *  public static final int var4; // suppressed violation
- *
- *  public void method1()
- *  {
- *    try {}
- *    catch(Exception ex) {} // suppressed violation
- *
- *    try {}
- *    catch(Exception ex) {} // suppressed violation
- *    catch(Error err) {} // suppressed violation
- *  }
- *
- *    //cson ConstantName
- *    //cson IllegalCatch
- *
- * }
- * 
- *

- * Example depicting use of checkC and checkCPP style comments - *

- *
- * <module name="SuppressionCommentFilter">
- *   <property name="checkC" value="true"/>
- *   <property name="checkCPP" value="false"/>
- * </module>
- * <module name="MemberName"/>
- * <module name="ConstantName"/>
- * <module name="IllegalCatch"/>
- * 
- *
- * class InputSuppressionCommentFilter
- * {
- *  int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *
- *  //CHECKSTYLE:OFF
- *  int VAR2; // violation , Name 'VAR2' must match pattern '^[a-z][a-zA-Z0-9]*$'
- *  //CHECKSTYLE:ON
- *
- *  public static final int var3;
- *  // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'
- *
- *  /*CHECKSTYLE:OFF*/
- *  public static final int var4; // suppressed violation
- *  /*CHECKSTYLE:ON*/
- *
- *  public void method1()
- *  {
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *
- *    //CHECKSTYLE:OFF
- *
- *    try {}
- *    catch(Exception ex) {} // violation , Catching 'Exception' is not allowed
- *    catch(Error err) {} // violation , Catching 'Error' is not allowed
- *
- *    //CHECKSTYLE:ON
- *  }
- * }
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilter.java index 5b7915834bc..2ee9a77b3ef 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilter.java @@ -123,97 +123,6 @@ * * *

- * For example, the following configuration fragment directs the Checker to use - * a {@code SuppressionFilter} with suppressions file {@code config/suppressions.xml}: - *

- *
- * <module name="SuppressionFilter">
- *   <property name="file" value="config/suppressions.xml"/>
- *   <property name="optional" value="false"/>
- * </module>
- * 
- *

- * The following suppressions XML document directs a {@code SuppressionFilter} to - * reject {@code JavadocStyleCheck} violations for lines 82 and 108 to 122 of file - * {@code AbstractComplexityCheck.java}, and {@code MagicNumberCheck} violations for - * line 221 of file {@code JavadocStyleCheck.java}, and - * {@code 'Missing a Javadoc comment'} violations for all lines and files: - *

- *
- * <?xml version="1.0"?>
- *
- * <!DOCTYPE suppressions PUBLIC
- *   "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
- *   "https://checkstyle.org/dtds/suppressions_1_2.dtd">
- *
- * <suppressions>
- *   <suppress checks="JavadocStyleCheck"
- *     files="AbstractComplexityCheck.java"
- *     lines="82,108-122"/>
- *   <suppress checks="MagicNumberCheck"
- *     files="JavadocStyleCheck.java"
- *     lines="221"/>
- *   <suppress message="Missing a Javadoc comment"/>
- * </suppressions>
- * 
- *

- * Suppress check by module id - * when config have two instances on the same check: - *

- *
- * <suppress id="stringEqual" files="SomeTestCode.java"/>
- * 
- *

- * Suppress all checks for hidden files and folders: - *

- *
- * <suppress files="[/\\]\..+" checks=".*"/>
- * 
- *

- * Suppress all checks for Maven-generated code: - *

- *
- * <suppress files="[/\\]target[/\\]" checks=".*"/>
- * 
- *

- * Suppress all checks for archives, classes and other binary files: - *

- *
- * <suppress files=".+\.(?:jar|zip|war|class|tar|bin)$" checks=".*"/>
- * 
- *

- * Suppress all checks for image files: - *

- *
- * <suppress files=".+\.(?:png|gif|jpg|jpeg)$" checks=".*"/>
- * 
- *

- * Suppress all checks for non-java files: - *

- *
- * <suppress files=".+\.(?:txt|xml|csv|sh|thrift|html|sql|eot|ttf|woff|css|png)$"
- *     checks=".*"/>
- * 
- *

- * Suppress all checks in generated sources: - *

- *
- * <suppress checks=".*" files="com[\\/]mycompany[\\/]app[\\/]gen[\\/]"/>
- * 
- *

- * Suppress FileLength check on integration tests in certain folder: - *

- *
- * <suppress checks="FileLength"
- *   files="com[\\/]mycompany[\\/]app[\\/].*IT.java"/>
- * 
- *

- * Suppress naming violations on variable named 'log' in all files: - *

- *
- * <suppress message="Name 'log' must match pattern"/>
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.Checker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilter.java index 915b6d58d9d..dd13e170436 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilter.java @@ -86,111 +86,6 @@ * * *

- * The following suppressions directs a {@code SuppressionSingleFilter} to reject - * {@code JavadocStyleCheck} violations for lines 82 and 108 to 122 of file - * {@code AbstractComplexityCheck.java}, and - * {@code MagicNumberCheck} violations for line 221 of file - * {@code JavadocStyleCheck.java}, and {@code 'Missing a Javadoc comment'} violations for all lines - * and files: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="checks" value="JavadocStyleCheck"/>
- *   <property name="files" value="AbstractComplexityCheck.java"/>
- *   <property name="lines" value="82,108-122"/>
- * </module>
- * <module name="SuppressionSingleFilter">
- *   <property name="checks" value="MagicNumberCheck"/>
- *   <property name="files" value="JavadocStyleCheck.java"/>
- *   <property name="lines" value="221"/>
- * </module>
- * <module name="SuppressionSingleFilter">
- *   <property name="message" value="Missing a Javadoc comment"/>
- * </module>
- * 
- *

- * Suppress check by module id when config - * have two instances on the same check: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="id" value="stringEqual"/>
- *   <property name="files" value="SomeTestCode.java"/>
- * </module>
- * 
- *

- * Suppress all checks for hidden files and folders: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="files" value="[/\\]\..+"/>
- *   <property name="checks" value=".*"/>
- * </module>
- * 
- *

- * Suppress all checks for Maven-generated code: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="files" value="[/\\]target[/\\]"/>
- *   <property name="checks" value=".*"/>
- * </module>
- * 
- *

- * Suppress all checks for archives, classes and other binary files: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="files" value=".+\.(?:jar|zip|war|class|tar|bin)$"/>
- *   <property name="checks" value=".*"/>
- * </module>
- * 
- *

- * Suppress all checks for image files: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="files" value=".+\.(?:png|gif|jpg|jpeg)$"/>
- *   <property name="checks" value=".*"/>
- * </module>
- * 
- *

- * Suppress all checks for non-java files: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="files"
- *     value=".+\.(?:txt|xml|csv|sh|thrift|html|sql|eot|ttf|woff|css|png)$"/>
- *   <property name="checks" value=".*"/>
- * </module>
- * 
- *

- * Suppress all checks in generated sources: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="files" value="com[\\/]mycompany[\\/]app[\\/]gen[\\/]"/>
- *   <property name="checks" value=".*"/>
- * </module>
- * 
- *

- * Suppress FileLength check on integration tests in certain folder: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="files" value="com[\\/]mycompany[\\/]app[\\/].*IT.java"/>
- *   <property name="checks" value="FileLength"/>
- * </module>
- * 
- *

- * Suppress naming violations on variable named 'log' in all files: - *

- *
- * <module name="SuppressionSingleFilter">
- *   <property name="message" value="Name 'log' must match pattern"/>
- * </module>
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.Checker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilter.java index 4470a1968f1..3e76036d03f 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilter.java @@ -189,317 +189,6 @@ * * *

- * For example, the following configuration fragment directs the Checker to use a - * {@code SuppressionXpathFilter} with suppressions file {@code config/suppressions.xml}: - *

- *
- * <module name="SuppressionXpathFilter">
- *   <property name="file" value="config/suppressions.xml"/>
- *   <property name="optional" value="false"/>
- * </module>
- * 
- *

- * A - * suppressions XML document - * contains a set of {@code suppress} and {@code suppress-xpath} elements, - * where each {@code suppress-xpath} element can have the following attributes: - *

- *
    - *
  • - * {@code files} - a Pattern - * matched against the file name associated with an audit event. It is optional. - *
  • - *
  • - * {@code checks} - a Pattern - * matched against the name of the check associated with an audit event. - * Optional as long as {@code id} or {@code message} is specified. - *
  • - *
  • - * {@code message} - a Pattern - * matched against the message of the check associated with an audit event. - * Optional as long as {@code checks} or {@code id} is specified. - *
  • - *
  • - * {@code id} - a String matched against - * the ID of the check associated with an audit event. - * Optional as long as {@code checks} or {@code message} is specified. - *
  • - *
  • - * {@code query} - a String xpath query. It is optional. - *
  • - *
- *

- * Each audit event is checked against each {@code suppress} and {@code suppress-xpath} element. - * It is suppressed if all specified attributes match against the audit event. - *

- *

- * ATTENTION: filtering by message is dependent on runtime locale. - * If project is running in different languages it is better to avoid filtering by message. - *

- *

- * The following suppressions XML document directs a {@code SuppressionXpathFilter} to reject - * {@code CyclomaticComplexity} violations for all methods with name sayHelloWorld inside - * FileOne and FileTwo files: - *

- *

- * Currently, xpath queries support one type of attribute {@code @text}. {@code @text} - - * addresses to the text value of the node. For example: variable name, annotation name, - * text content, etc. Only the following token types support {@code @text} attribute: - * {@code TokenTypes.IDENT}, {@code TokenTypes.STRING_LITERAL}, {@code TokenTypes.CHAR_LITERAL}, - * {@code TokenTypes.NUM_LONG}, {@code TokenTypes.NUM_INT}, {@code TokenTypes.NUM_DOUBLE}, - * {@code TokenTypes.NUM_FLOAT}. - * These token types were selected because only their text values are different - * in content from token type and represent text value from file and can be used - * in xpath queries for more accurate results. Other token types always have constant values. - *

- *
- * <?xml version="1.0"?>
- *
- * <!DOCTYPE suppressions PUBLIC
- * "-//Checkstyle//DTD SuppressionXpathFilter Experimental Configuration 1.2//EN"
- * "https://checkstyle.org/dtds/suppressions_1_2_xpath_experimental.dtd">
- *
- * <suppressions>
- *   <suppress-xpath checks="CyclomaticComplexity"
- *   files="FileOne.java,FileTwo.java"
- *   query="//METHOD_DEF[./IDENT[@text='sayHelloWorld']]"/>
- * </suppressions>
- * 
- *

- * Suppress checks for package definitions: - *

- *
- * <suppress-xpath checks=".*" query="/PACKAGE_DEF"/>
- * 
- *

- * Suppress checks for parent element of the first variable definition: - *

- *
- * <suppress-xpath checks=".*" query="(//VARIABLE_DEF)[1]/.."/>
- * 
- *

- * Suppress checks for elements which are either class definitions, either method definitions. - *

- *
- * <suppress-xpath checks=".*" query="//CLASS_DEF | //METHOD_DEF"/>
- * 
- *

- * Suppress checks for certain methods: - *

- *
- * <suppress-xpath checks=".*" query="//METHOD_DEF[./IDENT[@text='getSomeVar'
- *           or @text='setSomeVar']]"/>
- * 
- *

- * Suppress checks for variable testVariable inside testMethod - * method inside TestClass class. - *

- *
- * <suppress-xpath checks=".*" query="//CLASS_DEF[@text='TestClass']
- *           //METHOD_DEF[./IDENT[@text='testMethod']]
- *           //VARIABLE_DEF[./IDENT[@text='testVariable']]"/>
- * 
- *

- * In the following sample, violations for {@code LeftCurly} check will be suppressed - * for classes with name Main or for methods with name calculate. - *

- *
- * <suppress-xpath checks="LeftCurly" query="//CLASS_DEF[./IDENT[@text='Main']]//*
- *           | //METHOD_DEF[./IDENT[@text='calculate']]/*"/>
- * 
- *

- * The following example demonstrates how to suppress {@code RequireThis} violations - * for variable age inside changeAge method. - *

- *
- * <suppress-xpath checks="RequireThis"
- *      query="//CLASS_DEF[./IDENT[@text='InputTest']]
- *           //METHOD_DEF[./IDENT[@text='changeAge']]//ASSIGN/IDENT[@text='age']"/>
- * 
- *
- * public class InputTest {
- *   private int age = 23;
- *
- *   public void changeAge() {
- *     age = 24; //violation will be suppressed
- *   }
- * }
- * 
- *

- * Suppress {@code IllegalThrows} violations only for methods with name throwsMethod - * and only for {@code RuntimeException} exceptions. Double colon is used for axis iterations. - * In the following example {@code ancestor} axis is used to iterate all ancestor nodes - * of the current node with type {@code METHOD_DEF} and name throwsMethod. - * Please read more about xpath axes at - * W3Schools Xpath Axes. - *

- *
- * <suppress-xpath checks="IllegalThrows" query="//LITERAL_THROWS
- *           /IDENT[@text='RuntimeException' and
- *           ./ancestor::METHOD_DEF[./IDENT[@text='throwsMethod']]]"/>
- * 
- *
- * public class InputTest {
- *   public void throwsMethod() throws RuntimeException { // violation will be suppressed
- *   }
- *
- *   public void sampleMethod() throws RuntimeException { // will throw violation here
- *   }
- * }
- * 
- *

- * The following sample demonstrates how to suppress all violations for method - * itself and all descendants. {@code descendant-or-self} axis iterates through - * current node and all children nodes at any level. Keyword {@code node()} - * selects node elements. Please read more about xpath syntax at - * W3Schools Xpath Syntax. - *

- *
- * <suppress-xpath checks=".*" query="//METHOD_DEF[./IDENT[@text='legacyMethod']]
- *           /descendant-or-self::node()"/>
- * 
- *

- * Some elements can be suppressed in different ways. For example, to suppress - * violation on variable {@code wordCount} in following code: - *

- *
- * public class InputTest {
- *     private int wordCount = 11;
- * }
- * 
- *

- * You need to look at AST of such code by our CLI tool: - *

- *
- * $ java -jar checkstyle-X.XX-all.jar -t InputTest.java
- * CLASS_DEF -> CLASS_DEF [1:0]
- * |--MODIFIERS -> MODIFIERS [1:0]
- * |   `--LITERAL_PUBLIC -> public [1:0]
- * |--LITERAL_CLASS -> class [1:7]
- * |--IDENT -> InputTest [1:13]
- * `--OBJBLOCK -> OBJBLOCK [1:23]
- * |--LCURLY -> { [1:23]
- * |--VARIABLE_DEF -> VARIABLE_DEF [2:4]
- * |   |--MODIFIERS -> MODIFIERS [2:4]
- * |   |   `--LITERAL_PRIVATE -> private [2:4]
- * |   |--TYPE -> TYPE [2:12]
- * |   |   `--LITERAL_INT -> int [2:12]
- * |   |--IDENT -> wordCount [2:16]
- * |   |--ASSIGN -> = [2:26]
- * |   |   `--EXPR -> EXPR [2:28]
- * |   |       `--NUM_INT -> 11 [2:28]
- * |   `--SEMI -> ; [2:30]
- * `--RCURLY -> } [3:0]
- * 
- *

- * The easiest way is to suppress by variable name. As you can see {@code VARIABLE_DEF} - * node refers to variable declaration statement and has child node with token type - * {@code IDENT} which is used for storing class, method, variable names. - *

- *

- * The following example demonstrates how variable can be queried by its name: - *

- *
- * <suppress-xpath checks="." query="//VARIABLE_DEF[
- *             ./IDENT[@text='wordCount']]"/>
- * 
- *

- * Another way is to suppress by variable value. Again, if you look at the printed - * AST tree above, you will notice that one of the grandchildren of {@code VARIABLE_DEF} - * node is responsible for storing variable value -{@code NUM_INT} with value 11. - *

- *

- * The following example demonstrates how variable can be queried by its value, - * same approach applies to {@code String, char, float, double, int, long} data types: - *

- *
- * <suppress-xpath checks="." query="//VARIABLE_DEF[.//NUM_INT[@text=11]]"/>
- * 
- *

- * Next example is about suppressing method with certain annotation by its name and element value. - *

- *
- * public class InputTest {
- *             @Generated("first") // should not be suppressed
- *             public void test1() {
- *             }
- *
- *             @Generated("second") // should be suppressed
- *             public void test2() {
- *             }
- *         }
- * 
- *

- * First of all we need to look at AST tree printed by our CLI tool: - *

- *
- * $ java -jar checkstyle-X.XX-all.jar -t InputTest.java
- * CLASS_DEF -> CLASS_DEF [1:0]
- * |--MODIFIERS -> MODIFIERS [1:0]
- * |   `--LITERAL_PUBLIC -> public [1:0]
- * |--LITERAL_CLASS -> class [1:7]
- * |--IDENT -> InputTest [1:13]
- * `--OBJBLOCK -> OBJBLOCK [1:23]
- * |--LCURLY -> { [1:23]
- * |--METHOD_DEF -> METHOD_DEF [2:4]
- * |   |--MODIFIERS -> MODIFIERS [2:4]
- * |   |   |--ANNOTATION -> ANNOTATION [2:4]
- * |   |   |   |--AT -> @ [2:4]
- * |   |   |   |--IDENT -> Generated [2:5]
- * |   |   |   |--LPAREN -> ( [2:14]
- * |   |   |   |--EXPR -> EXPR [2:15]
- * |   |   |   |   `--STRING_LITERAL -> "first" [2:15]
- * |   |   |   `--RPAREN -> ) [2:22]
- * |   |   `--LITERAL_PUBLIC -> public [3:4]
- * |   |--TYPE -> TYPE [3:11]
- * |   |   `--LITERAL_VOID -> void [3:11]
- * |   |--IDENT -> test1 [3:16]
- * |   |--LPAREN -> ( [3:21]
- * |   |--PARAMETERS -> PARAMETERS [3:22]
- * |   |--RPAREN -> ) [3:22]
- * |   `--SLIST -> { [3:24]
- * |       `--RCURLY -> } [4:4]
- * |--METHOD_DEF -> METHOD_DEF [6:4]
- * |   |--MODIFIERS -> MODIFIERS [6:4]
- * |   |   |--ANNOTATION -> ANNOTATION [6:4]
- * |   |   |   |--AT -> @ [6:4]
- * |   |   |   |--IDENT -> Generated [6:5]
- * |   |   |   |--LPAREN -> ( [6:14]
- * |   |   |   |--EXPR -> EXPR [6:15]
- * |   |   |   |   `--STRING_LITERAL -> "second" [6:15]
- * |   |   |   `--RPAREN -> ) [6:23]
- * |   |   `--LITERAL_PUBLIC -> public [7:4]
- * |   |--TYPE -> TYPE [7:11]
- * |   |   `--LITERAL_VOID -> void [7:11]
- * |   |--IDENT -> test2 [7:16]
- * |   |--LPAREN -> ( [7:21]
- * |   |--PARAMETERS -> PARAMETERS [7:22]
- * |   |--RPAREN -> ) [7:22]
- * |   `--SLIST -> { [7:24]
- * |       `--RCURLY -> } [8:4]
- * `--RCURLY -> } [9:0]
- * 
- *

- * AST node {@code ANNOTATION -> ANNOTATION [6:4]} has direct child - * {@code IDENT -> Generated [6:5]}, therefore can be queried by {@code IDENT} value: - *

- *
- * <suppress-xpath checks="." query="//METHOD_DEF[
- *             .//ANNOTATION/IDENT[@text='Generated']]"/>
- * 
- *

- * The problem with query above that it will suppress violations for all methods - * with annotation {@code @Generated}. In order to suppress methods with - * {@code @Generated("second")} annotations only, you need to look at AST tree again. - * Value of the {@code ANNOTATION} node is stored inside sub-node with token type - * {@code STRING_LITERAL}. Use the following query to suppress methods with - * {@code @Generated("second")} annotation: - *

- *
- * <suppress-xpath checks="." query="//METHOD_DEF[.//ANNOTATION[
- *             ./IDENT[@text='Generated'] and ./EXPR/STRING_LITERAL[@text='second']]]"/>
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker} *

* diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilter.java b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilter.java index 4a26458eea7..e8a4dd1b60d 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilter.java @@ -79,331 +79,6 @@ * * *

- * To configure to suppress the MethodName check for all methods with - * name MyMethod inside FileOne and FileTwo files: - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="files" value="File(One|Two)\.java"/>
- *   <property name="checks" value="MethodName"/>
- *   <property name="query" value="(//CLASS_DEF[@text='FileOne']/OBJBLOCK/
- *             METHOD_DEF[@text='MyMethod']/IDENT)|
- *             (//CLASS_DEF[@text='FileTwo']/OBJBLOCK/METHOD_DEF[@text='MyMethod']/IDENT)"/>
- * </module>
- * 
- *

- * Code example: - *

- *
- * public class FileOne {
- *   public void MyMethod() {} // OK
- * }
- *
- * public class FileTwo {
- *   public void MyMethod() {} // OK
- * }
- *
- * public class FileThree {
- *   public void MyMethod() {} // violation, name 'MyMethod'
- *                             // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- * 
- *

- * To suppress MethodName check for method names matched pattern 'MyMethod[0-9]': - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value="MethodName"/>
- *   <property name="message" value="MyMethod[0-9]"/>
- * </module>
- * 
- *

- * Code Example: - *

- *
- * public class FileOne {
- *   public void MyMethod1() {} // OK
- *   public void MyMethod2() {} // OK
- *   public void MyMethodA() {} // violation, name 'MyMethodA' must
- *                              // match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- * 
- *

- * To suppress checks being specified by id property: - *

- *
- * <module name="MethodName">
- *   <property name="id" value="MethodName1"/>
- *   <property name="format" value="^[a-z](_?[a-zA-Z0-9]+)*$"/>
- * <module/>
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="files" value="FileOne.java"/>
- *   <property name="id" value="MethodName1"/>
- * <module/>
- * 
- *

- * Code example: - *

- *
- * public class FileOne {
- *   public void MyMethod() {} // OK
- * }
- * public class FileTwo {
- *   public void MyMethod() {} // violation,  name 'MyMethod' must
- *                             //match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- * 
- *

- * To suppress checks for all package definitions: - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value="PackageName"/>
- *   <property name="query" value="/PACKAGE_DEF[@text='File']/IDENT"/>
- * </module>
- * 
- *

- * Code example: - *

- *
- * package File; // OK
- *
- * public class FileOne {}
- * 
- *

- * To suppress RedundantModifier check for interface definitions: - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value="RedundantModifier"/>
- *   <property name="query" value="//INTERFACE_DEF//*"/>
- * <module/>
- * 
- *

- * Code Example: - *

- *
- * public interface TestClass {
- *   public static final int CONSTANT1 = 1;  // OK
- * }
- * 
- *

- * To suppress checks in the FileOne file by non-query: - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="files" value="FileOne.java"/>
- *   <property name="checks" value="MyMethod"/>
- * </module>
- * 
- *

- * Code example: - *

- *
- * public class FileOne {
- *   public void MyMethod() {} // OK
- * }
- *
- * public class FileTwo {
- *   public void MyMethod() {} // violation, name 'MyMethod'
- *                             // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- * 
- *

- * Suppress checks for elements which are either class definitions, either method definitions: - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value=".*"/>
- *   <property name="query"
- *             value="(//CLASS_DEF[@text='FileOne'])|
- *             (//CLASS_DEF[@text='FileOne']/OBJBLOCK/METHOD_DEF[@text='MyMethod']/IDENT)"/>
- * </module>
- * 
- *

- * Code example: - *

- *
- * abstract class FileOne { // OK
- *   public void MyMethod() {} // OK
- * }
- *
- * abstract class FileTwo { // violation of the AbstractClassName check,
- *                          // it should match the pattern "^Abstract.+$"
- *   public void MyMethod() {} // violation, name 'MyMethod'
- *                             // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- * 
- *

- * Suppress checks for MyMethod1 or MyMethod2 methods: - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value="MethodName"/>
- *   <property name="query" value="//CLASS_DEF[@text='FileOne']/OBJBLOCK/
- *             METHOD_DEF[@text='MyMethod1' or @text='MyMethod2']/IDENT"/>
- * </module>
- * 
- *

- * Code example: - *

- *
- * public class FileOne {
- *   public void MyMethod1() {} // OK
- *   public void MyMethod2() {} // OK
- *   public void MyMethod3() {} // violation, name 'MyMethod3' must
- *                              // match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- * }
- * 
- *

- * Suppress checks for variable testVariable inside testMethod method inside TestClass class: - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value="LocalFinalVariableName"/>
- *   <property name="query" value="//CLASS_DEF[@text='TestClass']/OBJBLOCK
- *         /METHOD_DEF[@text='testMethod']/SLIST
- *         /VARIABLE_DEF[@text='testVariable1']/IDENT"/>
- * </module>
- * 
- *

- * Code Example: - *

- *
- * public class TestClass {
- *   public void testMethod() {
- *     final int testVariable1 = 10; // OK
- *     final int testVariable2 = 10; // violation of the LocalFinalVariableName check,
- *                                   // name 'testVariable2' must match pattern '^[A-Z][A-Z0-9]*$'
- *   }
- * }
- * 
- *

- * In the following sample, violations for LeftCurly check will be suppressed - * for classes with name Main or for methods with name calculate. - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value="LeftCurly"/>
- *   <property name="query" value="//CLASS_DEF[@text='TestClass']/OBJBLOCK
- *         /METHOD_DEF[@text='testMethod1']/SLIST*"/>
- * </module>
- * 
- *

- * Code Example: - *

- *
- * public class TestClass {
- *   public void testMethod1()
- *   { // OK
- *   }
- *
- *   public void testMethod2()
- *   { // violation, '{' should be on the previous line
- *   }
- * }
- * 
- *

- * The following example demonstrates how to suppress RequireThis violations for - * variable age inside changeAge method. - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value="RequireThis"/>
- *   <property name="query" value="//CLASS_DEF[@text='InputTest']
- *         //METHOD_DEF[@text='changeAge']//ASSIGN[@text='age']/IDENT"/>
- * </module>
- * 
- *

- * Code Example: - *

- *
- * public class InputTest {
- *   private int age = 23;
- *
- *   public void changeAge() {
- *     age = 24; // violation will be suppressed
- *   }
- * }
- * 
- *

- * Suppress {@code IllegalThrows} violations only for methods with name - * throwsMethod and only for {@code RuntimeException} exceptions. - * Double colon is used for axis iterations. In the following example - * {@code ancestor} axis is used to iterate all ancestor nodes of the current - * node with type {@code METHOD_DEF} and name throwsMethod. - * Please read more about xpath axes at - * W3Schools Xpath Axes. - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value="IllegalThrows"/>
- *   <property name="query" value="//LITERAL_THROWS/IDENT[
- *       ..[@text='RuntimeException'] and ./ancestor::METHOD_DEF[@text='throwsMethod']]"/>
- * </module>
- * 
- *

- * Code Example: - *

- *
- * public class InputTest {
- *   public void throwsMethod() throws RuntimeException { // violation will be suppressed
- *   }
- *
- *   public void sampleMethod() throws RuntimeException { // will throw violation here
- *   }
- * }
- * 
- *

- * The following sample demonstrates how to suppress all violations for method - * itself and all descendants. {@code descendant-or-self} axis iterates through - * current node and all children nodes at any level. Keyword {@code node()} - * selects node elements. Please read more about xpath syntax at - * W3Schools Xpath Syntax. - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="checks" value=".*"/>
- *   <property name="query" value="//METHOD_DEF[@text='TestMethod1']
- *         /descendant-or-self::node()"/>
- * </module>
- * 
- *

- * Code Example: - *

- *
- * public class TestClass {
- *   public void TestMethod1() { // OK
- *     final int num = 10; // OK
- *   }
- *
- *   public void TestMethod2() { // violation of the MethodName check,
- *                               // name 'TestMethod2' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
- *     final int num = 10; // violation of the LocalFinalVariableName check,
- *                         // name 'num' must match pattern '^[A-Z][A-Z0-9]*$'
- *   }
- * }
- * 
- *

- * The following example is an example of what checks would be suppressed while - * building Spring projects with checkstyle plugin. Please find more information at: - * spring-javaformat - *

- *
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="files" value="[\\/]src[\\/]test[\\/]java[\\/]"/>
- *   <property name="checks" value="Javadoc*"/>
- * </module>
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="files" value=".*Tests\.java">
- *   <property name="checks" value="Javadoc*">
- * </module>
- * <module name="SuppressionXpathSingleFilter">
- *   <property name="files" value="generated-sources">
- *   <property name="checks" value="[a-zA-Z0-9]*">
- * </module>
- * 
- *

* Parent is {@code com.puppycrawl.tools.checkstyle.TreeWalker} *

* diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java index af0edbc9c62..5b3433f997c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java @@ -292,7 +292,17 @@ public class XdocsJavaDocsTest extends AbstractModuleTestSupport { "RecordComponentName", "RecordTypeParameterName", "StaticVariableName", - "TypeName" + "TypeName", + "SeverityMatchFilter", + "SuppressionCommentFilter", + "SuppressionFilter", + "SuppressionSingleFilter", + "SuppressionXpathFilter", + "SuppressionXpathSingleFilter", + "SuppressWarningsFilter", + "SuppressWithNearbyCommentFilter", + "SuppressWithNearbyTextFilter", + "SuppressWithPlainTextCommentFilter" ); private static final List> CHECK_PROPERTIES = new ArrayList<>(); diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterExamplesTest.java new file mode 100644 index 00000000000..d54dd12bf01 --- /dev/null +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterExamplesTest.java @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code and other text files for adherence to a set of rules. +// Copyright (C) 2001-2023 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/////////////////////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.filters; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; + +@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") +public class SeverityMatchFilterExamplesTest extends AbstractExamplesModuleTestSupport { + @Override + protected String getPackageLocation() { + return "com/puppycrawl/tools/checkstyle/filters/severitymatchfilter"; + } + + @Test + public void testExample1() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example1.txt"), expected); + } +} diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilterExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilterExamplesTest.java new file mode 100644 index 00000000000..1ceec6cfe7d --- /dev/null +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilterExamplesTest.java @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code and other text files for adherence to a set of rules. +// Copyright (C) 2001-2023 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/////////////////////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.filters; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; + +@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") +public class SuppressWarningsFilterExamplesTest extends AbstractExamplesModuleTestSupport { + @Override + protected String getPackageLocation() { + return "com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter"; + } + + @Test + public void testExample1() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example1.txt"), expected); + } + + @Test + public void testExample2() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example2.txt"), expected); + } +} diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilterExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilterExamplesTest.java new file mode 100644 index 00000000000..ee45af1baf1 --- /dev/null +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilterExamplesTest.java @@ -0,0 +1,105 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code and other text files for adherence to a set of rules. +// Copyright (C) 2001-2023 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/////////////////////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.filters; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; + +@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") +public class SuppressWithNearbyCommentFilterExamplesTest extends AbstractExamplesModuleTestSupport { + @Override + protected String getPackageLocation() { + return "com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter"; + } + + @Test + public void testExample1() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example1.txt"), expected); + } + + @Test + public void testExample2() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example2.txt"), expected); + } + + @Test + public void testExample3() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example3.txt"), expected); + } + + @Test + public void testExample4() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example4.txt"), expected); + } + + @Test + public void testExample5() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example5.txt"), expected); + } + + @Test + public void testExample6() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example6.txt"), expected); + } + + @Test + public void testExample7() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example7.txt"), expected); + } + + @Test + public void testExample8() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example8.txt"), expected); + } +} diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilterExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilterExamplesTest.java new file mode 100644 index 00000000000..37f5e75f329 --- /dev/null +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilterExamplesTest.java @@ -0,0 +1,114 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code and other text files for adherence to a set of rules. +// Copyright (C) 2001-2023 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/////////////////////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.filters; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; + +@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") +public class SuppressWithNearbyTextFilterExamplesTest extends AbstractExamplesModuleTestSupport { + @Override + protected String getPackageLocation() { + return "com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter"; + } + + @Test + public void testExample1() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example1.txt"), expected); + } + + @Test + public void testExample2() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example2.txt"), expected); + } + + @Test + public void testExample3() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example3.txt"), expected); + } + + @Test + public void testExample4() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example4.txt"), expected); + } + + @Test + public void testExample5() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example5.txt"), expected); + } + + @Test + public void testExample6() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example6.txt"), expected); + } + + @Test + public void testExample7() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example7.txt"), expected); + } + + @Test + public void testExample8() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example8.txt"), expected); + } + + @Test + public void testExample9() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example9.txt"), expected); + } +} diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilterExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilterExamplesTest.java new file mode 100644 index 00000000000..7997aa270ea --- /dev/null +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilterExamplesTest.java @@ -0,0 +1,106 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code and other text files for adherence to a set of rules. +// Copyright (C) 2001-2023 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/////////////////////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.filters; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; + +@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") +public class SuppressWithPlainTextCommentFilterExamplesTest + extends AbstractExamplesModuleTestSupport { + @Override + protected String getPackageLocation() { + return "com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter"; + } + + @Test + public void testExample1() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example1.txt"), expected); + } + + @Test + public void testExample2() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example2.txt"), expected); + } + + @Test + public void testExample3() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example3.txt"), expected); + } + + @Test + public void testExample4() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example4.txt"), expected); + } + + @Test + public void testExample5() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example5.txt"), expected); + } + + @Test + public void testExample6() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example6.txt"), expected); + } + + @Test + public void testExample7() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example7.txt"), expected); + } + + @Test + public void testExample8() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example8.txt"), expected); + } +} diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilterExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilterExamplesTest.java new file mode 100644 index 00000000000..de98402b6e4 --- /dev/null +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilterExamplesTest.java @@ -0,0 +1,105 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code and other text files for adherence to a set of rules. +// Copyright (C) 2001-2023 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/////////////////////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.filters; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; + +@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") +public class SuppressionCommentFilterExamplesTest extends AbstractExamplesModuleTestSupport { + @Override + protected String getPackageLocation() { + return "com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter"; + } + + @Test + public void testExample1() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example1.txt"), expected); + } + + @Test + public void testExample2() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example2.txt"), expected); + } + + @Test + public void testExample3() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example3.txt"), expected); + } + + @Test + public void testExample4() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example4.txt"), expected); + } + + @Test + public void testExample5() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example5.txt"), expected); + } + + @Test + public void testExample6() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example6.txt"), expected); + } + + @Test + public void testExample7() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example7.txt"), expected); + } + + @Test + public void testExample8() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example8.txt"), expected); + } +} diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilterExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilterExamplesTest.java new file mode 100644 index 00000000000..72c32aa14f0 --- /dev/null +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilterExamplesTest.java @@ -0,0 +1,123 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code and other text files for adherence to a set of rules. +// Copyright (C) 2001-2023 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/////////////////////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.filters; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; + +@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") +public class SuppressionSingleFilterExamplesTest extends AbstractExamplesModuleTestSupport { + @Override + protected String getPackageLocation() { + return "com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter"; + } + + @Test + public void testExample1() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example1.txt"), expected); + } + + @Test + public void testExample2() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example2.txt"), expected); + } + + @Test + public void testExample3() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example3.txt"), expected); + } + + @Test + public void testExample4() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example4.txt"), expected); + } + + @Test + public void testExample5() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example5.txt"), expected); + } + + @Test + public void testExample6() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example6.txt"), expected); + } + + @Test + public void testExample7() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example7.txt"), expected); + } + + @Test + public void testExample8() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example8.txt"), expected); + } + + @Test + public void testExample9() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example9.txt"), expected); + } + + @Test + public void testExample10() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example10.txt"), expected); + } +} diff --git a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilterExamplesTest.java b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilterExamplesTest.java new file mode 100644 index 00000000000..f572d92ee78 --- /dev/null +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilterExamplesTest.java @@ -0,0 +1,159 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code and other text files for adherence to a set of rules. +// Copyright (C) 2001-2023 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +/////////////////////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.filters; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; + +@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") +public class SuppressionXpathSingleFilterExamplesTest extends AbstractExamplesModuleTestSupport { + @Override + protected String getPackageLocation() { + return "com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter"; + } + + @Test + public void testExample1() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example1.txt"), expected); + } + + @Test + public void testExample2() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example2.txt"), expected); + } + + @Test + public void testExample3() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example3.txt"), expected); + } + + @Test + public void testExample4() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example4.txt"), expected); + } + + @Test + public void testExample5() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example5.txt"), expected); + } + + @Test + public void testExample6() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example6.txt"), expected); + } + + @Test + public void testExample7() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example7.txt"), expected); + } + + @Test + public void testExample8() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example8.txt"), expected); + } + + @Test + public void testExample9() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example9.txt"), expected); + } + + @Test + public void testExample10() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example10.txt"), expected); + } + + @Test + public void testExample11() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example11.txt"), expected); + } + + @Test + public void testExample12() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example12.txt"), expected); + } + + @Test + public void testExample13() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example13.txt"), expected); + } + + @Test + public void testExample14() throws Exception { + final String[] expected = { + + }; + + verifyWithInlineConfigParser(getPath("Example14.txt"), expected); + } +} diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/severitymatchfilter/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/severitymatchfilter/Example1.txt new file mode 100644 index 00000000000..dd0cf5813aa --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/severitymatchfilter/Example1.txt @@ -0,0 +1,11 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example1.txt new file mode 100644 index 00000000000..408fc3aa3f4 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example1.txt @@ -0,0 +1,42 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +class InputSuppressionCommentFilter +{ + int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$' + + //CHECKSTYLE:OFF + int VAR2; // suppressed violation + //CHECKSTYLE:ON + + public static final int var3; + // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + + //CHECKSTYLE:OFF + public static final int var4; // suppressed violation + //CHECKSTYLE:ON + + public void method1() + { + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + + //CHECKSTYLE:OFF + + try {} + catch(Exception ex) {} // suppressed violation + catch(Error err) {} // suppressed violation + + //CHECKSTYLE:ON + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example2.txt new file mode 100644 index 00000000000..ec0966969ff --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example2.txt @@ -0,0 +1,46 @@ +/*xml + + + + + + + + + + + + +*/ + +// xdoc section -- start +class InputSuppressionCommentFilter +{ + int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$' + + //stop constant check + int VAR2; // violation , Name 'VAR2' must match pattern '^[a-z][a-zA-Z0-9]*$' + //resume constant check + + public static final int var3; + // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + + //stop constant check + public static final int var4; // suppressed violation + //resume constant check + + public void method1() + { + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + + //stop constant check + + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + catch(Error err) {} // violation , Catching 'Error' is not allowed + + //resume constant check + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example3.txt new file mode 100644 index 00000000000..2e67caf5ec9 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example3.txt @@ -0,0 +1,48 @@ +/*xml + + + + + + + + + + + + + +*/ + +// xdoc section -- start +class InputSuppressionCommentFilter +{ + int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$' + + //ILLEGAL OFF: Exception + int VAR2; // violation , Name 'VAR2' must match pattern '^[a-z][a-zA-Z0-9]*$' + //ILLEGAL ON: Exception + + public static final int var3; + // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + + //ILLEGAL OFF: Exception + public static final int var4; + // violation above , Name 'var4' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + //ILLEGAL ON: Exception + + public void method1() + { + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + + //ILLEGAL OFF: Exception + + try {} + catch(Exception ex) {} // suppressed violation + catch(Error err) {} // violation , Catching 'Error' is not allowed + + //ILLEGAL ON: Exception + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example4.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example4.txt new file mode 100644 index 00000000000..110bf33b282 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example4.txt @@ -0,0 +1,46 @@ +/*xml + + + + + + + + + + + + +*/ + +// xdoc section -- start +class InputSuppressionCommentFilter +{ + int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$' + + //CSOFF: MemberName + int VAR2; // suppressed violation + //CSON: MemberName + + public static final int var3; + // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + + //CSOFF: ConstantName + public static final int var4; // suppressed violation + //CSON: ConstantName + + public void method1() + { + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + + //CSOFF: IllegalCatch + + try {} + catch(Exception ex) {} // suppressed violation + catch(Error err) {} // suppressed violation + + //CSON: IllegalCatch + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example5.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example5.txt new file mode 100644 index 00000000000..200a5ea9efd --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example5.txt @@ -0,0 +1,47 @@ +/*xml + + + + + + + + + + + + +*/ + +// xdoc section -- start +class InputSuppressionCommentFilter +{ + int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$' + + //CHECKSTYLE_OFF: ALMOST_ALL + int VAR2; // suppressed violation + //CHECKSTYLE_ON: ALMOST_ALL + + public static final int var3; + // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + + //CHECKSTYLE_OFF: ALMOST_ALL + public static final int var4; + // violation above , Name 'var4' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + //CHECKSTYLE_ON: ALMOST_ALL + + public void method1() + { + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + + //CHECKSTYLE_OFF: ALMOST_ALL + + try {} + catch(Exception ex) {} // suppressed violation + catch(Error err) {} // suppressed violation + + //CHECKSTYLE_ON: ALMOST_ALL + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example6.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example6.txt new file mode 100644 index 00000000000..29d3ba2809e --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example6.txt @@ -0,0 +1,52 @@ +/*xml + + + + + + + + + + + + + + + + + + +*/ + +// xdoc section -- start +class InputSuppressionCommentFilter +{ + int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$' + + //CSOFF MemberID + int VAR2; // suppressed violation + //CSON: MemberID + + public static final int var3; + // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + + //CSOFF ConstantID + public static final int var4; // suppressed violation + //CSON ConstantID + + public void method1() + { + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + + //CSOFF IllegalID + + try {} + catch(Exception ex) {} // suppressed violation + catch(Error err) {} // suppressed violation + + //CSON IllegalID + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example7.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example7.txt new file mode 100644 index 00000000000..1907a26e32b --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example7.txt @@ -0,0 +1,47 @@ +/*xml + + + + + + + + + + + + +*/ + +// xdoc section -- start +class InputSuppressionCommentFilter +{ + int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$' + + //csoff MemberName + int VAR2; // suppressed violation + //cson MemberName + + public static final int var3; + // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + + //csoff ConstantName + //csoff IllegalCatch + + public static final int var4; // suppressed violation + + public void method1() + { + try {} + catch(Exception ex) {} // suppressed violation + + try {} + catch(Exception ex) {} // suppressed violation + catch(Error err) {} // suppressed violation + } + + //cson ConstantName + //cson IllegalCatch + +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example8.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example8.txt new file mode 100644 index 00000000000..a20e6b89094 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter/Example8.txt @@ -0,0 +1,45 @@ +/*xml + + + + + + + + + + + +*/ + +// xdoc section -- start +class InputSuppressionCommentFilter +{ + int VAR1; // violation , Name 'VAR1' must match pattern '^[a-z][a-zA-Z0-9]*$' + + //CHECKSTYLE:OFF + int VAR2; // violation , Name 'VAR2' must match pattern '^[a-z][a-zA-Z0-9]*$' + //CHECKSTYLE:ON + + public static final int var3; + // violation above , Name 'var3' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$' + + /*CHECKSTYLE:OFF*/ + public static final int var4; // suppressed violation + /*CHECKSTYLE:ON*/ + + public void method1() + { + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + + //CHECKSTYLE:OFF + + try {} + catch(Exception ex) {} // violation , Catching 'Exception' is not allowed + catch(Error err) {} // violation , Catching 'Error' is not allowed + + //CHECKSTYLE:ON + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example1.txt new file mode 100644 index 00000000000..4517c955194 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example1.txt @@ -0,0 +1,20 @@ +/*xml + + + + + + + + + + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example10.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example10.txt new file mode 100644 index 00000000000..a9fecbc037d --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example10.txt @@ -0,0 +1,10 @@ +/*xml + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example2.txt new file mode 100644 index 00000000000..7348a477018 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example2.txt @@ -0,0 +1,11 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example3.txt new file mode 100644 index 00000000000..26f458acb19 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example3.txt @@ -0,0 +1,11 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example4.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example4.txt new file mode 100644 index 00000000000..613c5eb8875 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example4.txt @@ -0,0 +1,11 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example5.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example5.txt new file mode 100644 index 00000000000..a30577f920e --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example5.txt @@ -0,0 +1,11 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example6.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example6.txt new file mode 100644 index 00000000000..60e0680593a --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example6.txt @@ -0,0 +1,11 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example7.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example7.txt new file mode 100644 index 00000000000..8c6dfe09863 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example7.txt @@ -0,0 +1,12 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example8.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example8.txt new file mode 100644 index 00000000000..c51bebff08c --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example8.txt @@ -0,0 +1,11 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example9.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example9.txt new file mode 100644 index 00000000000..57f00573c64 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter/Example9.txt @@ -0,0 +1,11 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example1.txt new file mode 100644 index 00000000000..f785dcccc7f --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example1.txt @@ -0,0 +1,28 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +public class FileOne { + public void MyMethod() {} // OK +} + +public class FileTwo { + public void MyMethod() {} // OK +} + +public class FileThree { + public void MyMethod() {} // violation, name 'MyMethod' + // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$' +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example10.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example10.txt new file mode 100644 index 00000000000..84b8e8ff65d --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example10.txt @@ -0,0 +1,23 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public class TestClass { + public void testMethod1() + { // OK + } + + public void testMethod2() + { // violation, '{' should be on the previous line + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example11.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example11.txt new file mode 100644 index 00000000000..b25fba7f583 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example11.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public class InputTest { + private int age = 23; + + public void changeAge() { + age = 24; // violation will be suppressed + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example12.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example12.txt new file mode 100644 index 00000000000..94d8984c9a1 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example12.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public class InputTest { + public void throwsMethod() throws RuntimeException { // violation will be suppressed + } + + public void sampleMethod() throws RuntimeException { // will throw violation here + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example13.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example13.txt new file mode 100644 index 00000000000..8597877a9ea --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example13.txt @@ -0,0 +1,25 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public class TestClass { + public void TestMethod1() { // OK + final int num = 10; // OK + } + + public void TestMethod2() { // violation of the MethodName check, + // name 'TestMethod2' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$' + final int num = 10; // violation of the LocalFinalVariableName check, + // name 'num' must match pattern '^[A-Z][A-Z0-9]*$' + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example14.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example14.txt new file mode 100644 index 00000000000..103a2967f61 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example14.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + + + + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example2.txt new file mode 100644 index 00000000000..e6cfd695f9d --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example2.txt @@ -0,0 +1,19 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public class FileOne { + public void MyMethod1() {} // OK + public void MyMethod2() {} // OK + public void MyMethodA() {} // violation, name 'MyMethodA' must + // match pattern '^[a-z](_?[a-zA-Z0-9]+)*$' +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example3.txt new file mode 100644 index 00000000000..e26ea9ff23e --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example3.txt @@ -0,0 +1,24 @@ +/*xml + + + + + + + + + + + + +*/ + +// xdoc section -- start +public class FileOne { + public void MyMethod() {} // OK +} +public class FileTwo { + public void MyMethod() {} // violation, name 'MyMethod' must + //match pattern '^[a-z](_?[a-zA-Z0-9]+)*$' +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example4.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example4.txt new file mode 100644 index 00000000000..57ab017b55c --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example4.txt @@ -0,0 +1,16 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +package File; // OK + +public class FileOne {} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example5.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example5.txt new file mode 100644 index 00000000000..0a0b5a02720 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example5.txt @@ -0,0 +1,16 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public interface TestClass { + public static final int CONSTANT1 = 1; // OK +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example6.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example6.txt new file mode 100644 index 00000000000..db876233d8a --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example6.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public class FileOne { + public void MyMethod() {} // OK +} + +public class FileTwo { + public void MyMethod() {} // violation, name 'MyMethod' + // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$' +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example7.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example7.txt new file mode 100644 index 00000000000..f76e96aa67f --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example7.txt @@ -0,0 +1,24 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +abstract class FileOne { // OK + public void MyMethod() {} // OK +} + +abstract class FileTwo { // violation of the AbstractClassName check, + // it should match the pattern "^Abstract.+$" + public void MyMethod() {} // violation, name 'MyMethod' + // must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$' +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example8.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example8.txt new file mode 100644 index 00000000000..c46865ef294 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example8.txt @@ -0,0 +1,20 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public class FileOne { + public void MyMethod1() {} // OK + public void MyMethod2() {} // OK + public void MyMethod3() {} // violation, name 'MyMethod3' must + // match pattern '^[a-z](_?[a-zA-Z0-9]+)*$' +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example9.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example9.txt new file mode 100644 index 00000000000..34653a4ea7c --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter/Example9.txt @@ -0,0 +1,22 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +public class TestClass { + public void testMethod() { + final int testVariable1 = 10; // OK + final int testVariable2 = 10; // violation of the LocalFinalVariableName check, + // name 'testVariable2' must match pattern '^[A-Z][A-Z0-9]*$' + } +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/Example1.txt new file mode 100644 index 00000000000..3e5b47e15ae --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/Example1.txt @@ -0,0 +1,17 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +@SuppressWarnings({"memberName"}) +private int J; // should NOT fail MemberNameCheck + +@SuppressWarnings({"MemberName"}) +@SuppressWarnings({"NoWhitespaceAfter"}) +private int [] ARRAY; // should NOT fail MemberNameCheck and NoWhitespaceAfterCheck +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/Example2.txt new file mode 100644 index 00000000000..475bdfc3cbc --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter/Example2.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + + + + +*/ + +// xdoc section -- start +@SuppressWarnings("checkstyle:systemout") +public static void foo() { + System.out.println("Debug info."); // should NOT fail RegexpSinglelineJava +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example1.txt new file mode 100644 index 00000000000..5cdab78118b --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example1.txt @@ -0,0 +1,11 @@ +/*xml + + + + + +*/ + +// xdoc section -- start +private int [] array; // SUPPRESS CHECKSTYLE +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example2.txt new file mode 100644 index 00000000000..60ab6f5d6a1 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example2.txt @@ -0,0 +1,15 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +public static final int lowerCaseConstant; // CHECKSTYLE IGNORE THIS LINE +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example3.txt new file mode 100644 index 00000000000..47e75141e82 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example3.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + + + +*/ + +// xdoc section -- start +. . . +catch (RuntimeException re) { +// OK to catch RuntimeException here +} +catch (Throwable th) { ... } +. . . +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example4.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example4.txt new file mode 100644 index 00000000000..2d94ac962ce --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example4.txt @@ -0,0 +1,20 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +static final int lowerCaseConstant; // CHECKSTYLE IGNORE ConstantNameCheck FOR NEXT 3 LINES +static final int lowerCaseConstant1; +static final int lowerCaseConstant2; +static final int lowerCaseConstant3; +static final int lowerCaseConstant4; // will warn here +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example5.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example5.txt new file mode 100644 index 00000000000..e8d88e0e083 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example5.txt @@ -0,0 +1,18 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +private int D2; +// ALLOW MemberName ON PREVIOUS LINE +. . . +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example6.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example6.txt new file mode 100644 index 00000000000..1894ea39fdb --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example6.txt @@ -0,0 +1,16 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +public static final int [] array; // @cs.suppress [ConstantName|NoWhitespaceAfter] A comment here +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example7.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example7.txt new file mode 100644 index 00000000000..3a7e5f2916a --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example7.txt @@ -0,0 +1,33 @@ +/*xml + + + + + + + + + + + + + + + + + + + + +*/ + +// xdoc section -- start +@Ignore // @cs-: ignore (test has not been implemented yet) +@Test +public void testMethod() { } + +public static void foo() { + System.out.println("Debug info."); // @cs-: systemout (should not fail RegexpSinglelineJava) +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example8.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example8.txt new file mode 100644 index 00000000000..c1e0674aaeb --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter/Example8.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +// @cs-: ClassDataAbstractionCoupling influence 2 +// @cs-: MagicNumber influence 4 +@Service // no violations from ClassDataAbstractionCoupling here +@Transactional +public class UserService { + private int value = 10022; // no violations from MagicNumber here +} +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example1.txt new file mode 100644 index 00000000000..8f36444b62b --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example1.txt @@ -0,0 +1,13 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +int hoursInDay = 24; // SUPPRESS CHECKSTYLE because it is too obvious +int daysInWeek = 7; // violation +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example2.txt new file mode 100644 index 00000000000..f88461f5534 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example2.txt @@ -0,0 +1,15 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +int a = 42; // DO NOT CHECK THIS LINE +int b = 43; // violation +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example3.txt new file mode 100644 index 00000000000..c2d91924524 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example3.txt @@ -0,0 +1,15 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +export FOO=BAR # ok, because violation message is matching suppress pattern +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example4.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example4.txt new file mode 100644 index 00000000000..d859f281e79 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example4.txt @@ -0,0 +1,20 @@ +/*xml + + + + + + + + + + + + + +*/ + +// xdoc section -- start +int a = 42; // SUPPRESS CHECKSTYLE because i want to +static final int LONG_VAR_NAME_TO_TAKE_MORE_THAN_55_CHARS = 22; // LineLength violation +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example5.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example5.txt new file mode 100644 index 00000000000..e0054fbfba7 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example5.txt @@ -0,0 +1,15 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +key.one=41 # SUPPRESS CHECKSTYLE because I want to +key.one=42 # ok +key.one=43 # ok +key.one=44 # violation +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example6.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example6.txt new file mode 100644 index 00000000000..8437f28ba46 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example6.txt @@ -0,0 +1,15 @@ +/*xml + + + + + + +*/ + +// xdoc section -- start +key.one=41 # violation +key.one=42 # ok +key.one=43 # SUPPRESS CHECKSTYLE because I want to +key.one=44 # violation +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example7.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example7.txt new file mode 100644 index 00000000000..0b5c6345c83 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example7.txt @@ -0,0 +1,17 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +int a = 42; // -@cs[MagicNumber] We do not consider this number as magic for some reason. +int b = 43; // violation +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example8.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example8.txt new file mode 100644 index 00000000000..736e2de7d25 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example8.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + + + +*/ + +// xdoc section -- start +int a = 42; // @cs-: MagicNumber for +3 lines +int b = 43; +int c = 44; +int d = 45; +int e = 46; // violation +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example9.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example9.txt new file mode 100644 index 00000000000..901ab2ceb2f --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter/Example9.txt @@ -0,0 +1,21 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +/** +* Flag description. +* +* Disabled until // ok +*/ +public static final boolean SOME_FLAG = false; +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example1.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example1.txt new file mode 100644 index 00000000000..4b67f21232e --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example1.txt @@ -0,0 +1,8 @@ +/*xml + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example2.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example2.txt new file mode 100644 index 00000000000..285e941f10b --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example2.txt @@ -0,0 +1,19 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +//BEGIN GENERATED CONTENT +my.property=value1 // No violation events will be reported +my.property=value2 // No violation events will be reported +//END GENERATED CONTENT +. . . +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example3.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example3.txt new file mode 100644 index 00000000000..77d95a518e1 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example3.txt @@ -0,0 +1,19 @@ +/*xml + + + + + + + + + + +*/ + +// xdoc section -- start +-- stop tab check + SELECT * FROM users // won't warn here if there is a tab character on line +-- resume tab check + SELECT 1 // will warn here if there is a tab character on line +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example4.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example4.txt new file mode 100644 index 00000000000..1d3873f3a44 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example4.txt @@ -0,0 +1,23 @@ +/*xml + + + + + + + + + + +*/ + +// xdoc section -- start +// CSOFF: RegexpSinglelineCheck + // RegexpSingleline check won't warn any lines below here if the line matches regexp + + + +// CSON: RegexpSinglelineCheck +// RegexpSingleline check will warn below here if the line matches regexp + +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example5.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example5.txt new file mode 100644 index 00000000000..adf95b62f35 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example5.txt @@ -0,0 +1,23 @@ +/*xml + + + + + + + + + + +*/ + +// xdoc section -- start +// CHECKSTYLE_OFF: ALMOST_ALL +public static final int array []; +private String [] strArray; +// CHECKSTYLE_ON: ALMOST_ALL +private int array1 []; +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example6.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example6.txt new file mode 100644 index 00000000000..c6db413a2be --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example6.txt @@ -0,0 +1,14 @@ +/*xml + + + + + + + + +*/ + +// xdoc section -- start +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example7.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example7.txt new file mode 100644 index 00000000000..1d2e63dc09d --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example7.txt @@ -0,0 +1,40 @@ +/*xml + + + + + + + + + + + + + + + + + + + + + + + + +*/ + +// xdoc section -- start +-- CSOFF join (it is ok to use join here for performance reasons) +SELECT name, job_name +FROM users AS u +JOIN jobs AS j ON u.job_id = j.id +-- CSON join + +-- CSOFF count (test query execution plan) +EXPLAIN SELECT COUNT(*) FROM restaurants +-- CSON count +// xdoc section -- end diff --git a/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example8.txt b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example8.txt new file mode 100644 index 00000000000..81f29cd8c62 --- /dev/null +++ b/src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/Example8.txt @@ -0,0 +1,22 @@ +/*xml + + + + + + + + + +*/ + +// xdoc section -- start +-- @cs-: RegexpSinglelineCheck +-- @cs-: FileTabCharacterCheck +CREATE TABLE STATION ( + ID INTEGER PRIMARY KEY, + CITY CHAR(20), + STATE CHAR(2), + LAT_N REAL, + LONG_W REAL); +// xdoc section -- end diff --git a/src/xdocs/filters/severitymatchfilter.xml b/src/xdocs/filters/severitymatchfilter.xml index 013aa6252e6..93849a6f993 100644 --- a/src/xdocs/filters/severitymatchfilter.xml +++ b/src/xdocs/filters/severitymatchfilter.xml @@ -55,15 +55,17 @@ -

+

For example, the following configuration fragment directs the Checker to not report audit events with severity level info:

-<module name="SeverityMatchFilter"> - <property name="severity" value="info"/> - <property name="acceptOnMatch" value="false"/> +<module name="Checker"> + <module name="SeverityMatchFilter"> + <property name="severity" value="info"/> + <property name="acceptOnMatch" value="false"/> + </module> </module>
diff --git a/src/xdocs/filters/severitymatchfilter.xml.template b/src/xdocs/filters/severitymatchfilter.xml.template index 9036fea0376..ad251b6a9a3 100644 --- a/src/xdocs/filters/severitymatchfilter.xml.template +++ b/src/xdocs/filters/severitymatchfilter.xml.template @@ -55,17 +55,16 @@ -

+

For example, the following configuration fragment directs the Checker to not report audit events with severity level info:

- -<module name="SeverityMatchFilter"> - <property name="severity" value="info"/> - <property name="acceptOnMatch" value="false"/> -</module> - + + + +