Skip to content

Commit

Permalink
Issue #13345: Enable UnnecessarySemicolonAfterOuterTypeDeclarationChe…
Browse files Browse the repository at this point in the history
…ckExamplesTest
  • Loading branch information
prathm3 committed May 3, 2024
1 parent e5c995e commit 9f50210
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

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")
import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck.MSG_SEMI;

public class UnnecessarySemicolonAfterOuterTypeDeclarationCheckExamplesTest
extends AbstractExamplesModuleTestSupport {
@Override
Expand All @@ -36,18 +36,20 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {

"18:2: " + getCheckMessage(MSG_SEMI),
"22:2: " + getCheckMessage(MSG_SEMI),
"26:2: " + getCheckMessage(MSG_SEMI),
"30:2: " + getCheckMessage(MSG_SEMI)
};

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

@Test
public void testExample2() throws Exception {
final String[] expected = {

"16:2: " + getCheckMessage(MSG_SEMI)
};

verifyWithInlineConfigParser(getPath("Example2.txt"), expected);
verifyWithInlineConfigParser(getPath("Example2.java"), expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
</module>
*/

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

// xdoc section -- start
class A {

class Nested {
class Nested {

}; // OK, nested type declarations are ignored
}; // OK, nested type declarations are ignored

}; // violation

Expand All @@ -23,7 +25,7 @@ enum C {

}; // violation

{@literal @}interface D {
@interface D {

}; // violation
// xdoc section -- end
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@
</module>
*/

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

// xdoc section -- start
class A {
class S {

}; // violation

interface B {
interface T {

}; // OK

enum C {
enum U {

}; // OK

{@literal @}interface D {
@interface V {

}; // OK
// xdoc section -- end

Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,25 @@
Example:
</p>
<source>
class A {
class A {

class Nested {
class Nested {

}; // OK, nested type declarations are ignored
}; // OK, nested type declarations are ignored

}; // violation
}; // violation

interface B {
interface B {

}; // violation
}; // violation

enum C {
enum C {

}; // violation
}; // violation

{@literal @}interface D {
@interface D {

}; // violation
}; // violation
</source>
<p id="Example2-config">
To configure the check to detect unnecessary semicolon only after top level class
Expand All @@ -117,21 +117,21 @@ enum C {
Example:
</p>
<source>
class A {
class S {

}; // violation
}; // violation

interface B {
interface T {

}; // OK
}; // OK

enum C {
enum U {

}; // OK
}; // OK

{@literal @}interface D {
@interface V {

}; // OK
}; // OK
</source>
</subsection>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessarysemicolonafteroutertypedeclaration/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessarysemicolonafteroutertypedeclaration/Example1.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example1-code">
Example:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessarysemicolonafteroutertypedeclaration/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessarysemicolonafteroutertypedeclaration/Example1.java"/>
<param name="type" value="code"/>
</macro>
<p id="Example2-config">
Expand All @@ -52,15 +52,15 @@
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessarysemicolonafteroutertypedeclaration/Example2.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessarysemicolonafteroutertypedeclaration/Example2.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example2-code">
Example:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessarysemicolonafteroutertypedeclaration/Example2.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessarysemicolonafteroutertypedeclaration/Example2.java"/>
<param name="type" value="code"/>
</macro>
</subsection>
Expand Down

0 comments on commit 9f50210

Please sign in to comment.