Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #13345: Enabled SuppressionXpathSingleFilterExamplesTest #14748

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -19,12 +19,10 @@

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() {
Expand All @@ -37,7 +35,7 @@ public void testExample1() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}

@Test
Expand All @@ -46,7 +44,7 @@ public void testExample2() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}

@Test
Expand All @@ -55,7 +53,7 @@ public void testExample3() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example3.txt"), expected);
verifyWithInlineConfigParser(getPath("Example3.java"), expected);
}

@Test
Expand All @@ -64,7 +62,7 @@ public void testExample4() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example4.txt"), expected);
verifyWithInlineConfigParser(getPath("Example4.java"), expected);
}

@Test
Expand All @@ -73,7 +71,7 @@ public void testExample5() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example5.txt"), expected);
verifyWithInlineConfigParser(getPath("Example5.java"), expected);
}

@Test
Expand All @@ -82,7 +80,7 @@ public void testExample6() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example6.txt"), expected);
verifyWithInlineConfigParser(getPath("Example6.java"), expected);
}

@Test
Expand All @@ -91,7 +89,7 @@ public void testExample7() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example7.txt"), expected);
verifyWithInlineConfigParser(getPath("Example7.java"), expected);
}

@Test
Expand All @@ -100,7 +98,7 @@ public void testExample8() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example8.txt"), expected);
verifyWithInlineConfigParser(getPath("Example8.java"), expected);
}

@Test
Expand All @@ -109,7 +107,7 @@ public void testExample9() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example9.txt"), expected);
verifyWithInlineConfigParser(getPath("Example9.java"), expected);
}

@Test
Expand All @@ -118,7 +116,7 @@ public void testExample10() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example10.txt"), expected);
verifyWithInlineConfigParser(getPath("Example10.java"), expected);
}

@Test
Expand All @@ -127,7 +125,7 @@ public void testExample11() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example11.txt"), expected);
verifyWithInlineConfigParser(getPath("Example11.java"), expected);
}

@Test
Expand All @@ -136,7 +134,7 @@ public void testExample12() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example12.txt"), expected);
verifyWithInlineConfigParser(getPath("Example12.java"), expected);
}

@Test
Expand All @@ -145,7 +143,7 @@ public void testExample13() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example13.txt"), expected);
verifyWithInlineConfigParser(getPath("Example13.java"), expected);
}

@Test
Expand All @@ -154,6 +152,6 @@ public void testExample14() throws Exception {

};

verifyWithInlineConfigParser(getPath("Example14.txt"), expected);
verifyWithInlineConfigParser(getPath("Example14.java"), expected);
}
}
@@ -0,0 +1,14 @@
// 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

This file was deleted.

49 changes: 26 additions & 23 deletions src/xdocs/filters/suppressionxpathsinglefilter.xml
Expand Up @@ -113,8 +113,8 @@ public class FileTwo {
}

public class FileThree {
public void MyMethod() {} // violation, name 'MyMethod'
// must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
public void MyMethod() {}
// violation, name 'MyMethod' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
</source>
<p id="Example2-config">
Expand All @@ -135,8 +135,8 @@ public class FileThree {
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]+)*$'
public void MyMethodA() {}
// violation, name 'MyMethodA' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
</source>
<p id="Example3-config">
Expand All @@ -162,8 +162,8 @@ 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]+)*$'
public void MyMethod() {}
// violation, name 'MyMethod' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
</source>
<p id="Example4-config">
Expand Down Expand Up @@ -224,8 +224,8 @@ public class FileOne {
}

public class FileTwo {
public void MyMethod() {} // violation, name 'MyMethod'
// must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
public void MyMethod() {}
// violation, name 'MyMethod' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
</source>
<p id="Example7-config">
Expand All @@ -250,10 +250,10 @@ abstract class FileOne { // OK
public void MyMethod() {} // OK
}

abstract class FileTwo { // violation of the AbstractClassName check,
// it should match the pattern &quot;^Abstract.+$&quot;
public void MyMethod() {} // violation, name 'MyMethod'
// must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
abstract class FileTwo {
// violation of the AbstractClassName check, it should match the pattern &quot;^Abstract.+$&quot;
public void MyMethod() {}
// violation, name 'MyMethod' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
</source>
<p id="Example8-config">
Expand All @@ -275,8 +275,8 @@ abstract class FileTwo { // violation of the AbstractClassName check,
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]+)*$'
public void MyMethod3() {}
// violation, name 'MyMethod3' must match pattern '^[a-z](_?[a-zA-Z0-9]+)*$'
}
</source>
<p id="Example9-config">
Expand All @@ -300,8 +300,8 @@ public class FileOne {
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]*$'
final int testVariable2 = 10;
// violation of the LocalFinalVariableName check, name 'testVariable2' must match pattern '^[A-Z][A-Z0-9]*$'
}
}
</source>
Expand Down Expand Up @@ -354,7 +354,8 @@ public class InputTest {
private int age = 23;

public void changeAge() {
age = 24; // violation will be suppressed
age = 24;
// violation will be suppressed
}
}
</source>
Expand All @@ -380,10 +381,12 @@ public class InputTest {
<p id="Example12-code">Code Example:</p>
<source>
public class InputTest {
public void throwsMethod() throws RuntimeException { // violation will be suppressed
public void throwsMethod() throws RuntimeException {
// violation will be suppressed
}

public void sampleMethod() throws RuntimeException { // will throw violation here
public void sampleMethod() throws RuntimeException {
// will throw violation here
}
}
</source>
Expand Down Expand Up @@ -412,10 +415,10 @@ public class TestClass {
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]*$'
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]*$'
}
}
</source>
Expand Down