Skip to content

Commit

Permalink
Issue #13345: enable example test for SeverityMatchFilterExamplesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Kexin2000 committed Apr 11, 2024
1 parent ffbeac5 commit e14b1a8
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 19 deletions.
@@ -0,0 +1 @@
name.invalidPattern=Name ''{0}'' must match pattern ''{1}''.
Expand Up @@ -368,6 +368,10 @@ private static String getFullyQualifiedClassName(String filePath, String moduleN
"com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck");
moduleMappings.put("LineLength",
"com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck");
moduleMappings.put("ParameterName",
"com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck");
moduleMappings.put("MethodName",
"com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck");

String fullyQualifiedClassName;
if (moduleMappings.containsKey(moduleName)) {
Expand Down
Expand Up @@ -19,24 +19,26 @@

package com.puppycrawl.tools.checkstyle.filters;

import org.junit.jupiter.api.Disabled;
import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN;

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 = {
public void testExample() throws Exception {
final String pattern = "^[a-z][a-zA-Z0-9]*$";

final String[] expected = {
"22:15: " + getCheckMessage(MSG_INVALID_PATTERN, "Method2", pattern),
};

verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
verifyWithInlineConfigParser(getPath("Example.java"), expected);
}
}
@@ -0,0 +1,24 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="ParameterName">
<property name="severity" value="info"/>
</module>
<module name="MethodName"/>
</module>
<module name="SeverityMatchFilter">
<property name="severity" value="info"/>
<property name="acceptOnMatch" value="false"/>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.filters.severitymatchfilter;

// xdoc section -- start
public class Example {

public void method1(int V1){} // ok, ParameterNameCheck's severity is info

public void Method2(){} // violation
}
// xdoc section -- end

This file was deleted.

8 changes: 7 additions & 1 deletion src/xdocs/filters/severitymatchfilter.xml
Expand Up @@ -48,13 +48,19 @@
</div>
</subsection>
<subsection name="Examples" id="Examples">
<p id="Example1-config">
<p id="Example-config">
For example, the following configuration fragment directs the
Checker to not report audit events with severity
level <code>info</code>:
</p>
<source>
&lt;module name=&quot;Checker&quot;&gt;
&lt;module name=&quot;TreeWalker&quot;&gt;
&lt;module name=&quot;ParameterName&quot;&gt;
&lt;property name=&quot;severity&quot; value=&quot;info&quot;/&gt;
&lt;/module&gt;
&lt;module name=&quot;MethodName&quot;/&gt;
&lt;/module&gt;
&lt;module name=&quot;SeverityMatchFilter&quot;&gt;
&lt;property name=&quot;severity&quot; value=&quot;info&quot;/&gt;
&lt;property name=&quot;acceptOnMatch&quot; value=&quot;false&quot;/&gt;
Expand Down
4 changes: 2 additions & 2 deletions src/xdocs/filters/severitymatchfilter.xml.template
Expand Up @@ -29,14 +29,14 @@
</div>
</subsection>
<subsection name="Examples" id="Examples">
<p id="Example1-config">
<p id="Example-config">
For example, the following configuration fragment directs the
Checker to not report audit events with severity
level <code>info</code>:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/filters/severitymatchfilter/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/filters/severitymatchfilter/Example.java"/>
<param name="type" value="config"/>
</macro>
</subsection>
Expand Down

0 comments on commit e14b1a8

Please sign in to comment.