Skip to content

Commit

Permalink
Issue checkstyle#13345: Enable examples tests for NoArrayTrailingComm…
Browse files Browse the repository at this point in the history
…aCheck
  • Loading branch information
AmitKumarDeoghoria authored and romani committed Nov 6, 2024
1 parent f58f26f commit 42b9ce9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@

package com.puppycrawl.tools.checkstyle.checks.coding;

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 NoArrayTrailingCommaCheckExamplesTest extends AbstractExamplesModuleTestSupport {
@Override
protected String getPackageLocation() {
Expand All @@ -34,9 +32,10 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {

"15:12: " + getCheckMessage(NoArrayTrailingCommaCheck.MSG_KEY),
"18:35: " + getCheckMessage(NoArrayTrailingCommaCheck.MSG_KEY),
};

verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="NoArrayTrailingComma"/>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.coding.noarraytrailingcomma;

// xdoc section -- start
class Example1 {
void InvalidExample() {
String[] foo1 = {
"FOO",
"BAR", // violation, 'Array should not contain trailing comma'
};
// violation below, 'Array should not contain trailing comma'
String[] foo2 = { "FOO", "BAR", };
String[] foo3 = {
"FOO",
"BAR"
};
String[] foo4 = { "FOO", "BAR" };
}
}
// xdoc section -- end

This file was deleted.

25 changes: 15 additions & 10 deletions src/xdocs/checks/coding/noarraytrailingcomma.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ String[] foo = new String[] {
Which results in the following violations:
</p>
<source>
String[] foo1 = {
&quot;FOO&quot;, // OK
&quot;BAR&quot;, // violation
};
String[] foo2 = { &quot;FOO&quot;, &quot;BAR&quot;, }; // violation
String[] foo3 = {
&quot;FOO&quot;, // OK
&quot;BAR&quot; // OK
};
String[] foo4 = { &quot;FOO&quot;, &quot;BAR&quot; }; // OK
class Example1 {
void InvalidExample() {
String[] foo1 = {
&quot;FOO&quot;,
&quot;BAR&quot;, // violation, 'Array should not contain trailing comma'
};
// violation below, 'Array should not contain trailing comma'
String[] foo2 = { &quot;FOO&quot;, &quot;BAR&quot;, };
String[] foo3 = {
&quot;FOO&quot;,
&quot;BAR&quot;
};
String[] foo4 = { &quot;FOO&quot;, &quot;BAR&quot; };
}
}
</source>
</subsection>
<subsection name="Example of Usage" id="Example_of_Usage">
Expand Down
4 changes: 2 additions & 2 deletions src/xdocs/checks/coding/noarraytrailingcomma.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ String[] foo = new String[] {
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/noarraytrailingcomma/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/noarraytrailingcomma/Example1.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example1-code">
Which results in the following violations:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/noarraytrailingcomma/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/noarraytrailingcomma/Example1.java"/>
<param name="type" value="code"/>
</macro>
</subsection>
Expand Down

0 comments on commit 42b9ce9

Please sign in to comment.