Skip to content

Commit

Permalink
Issue checkstyle#15456: Specify violation messages for OuterTypeFilen…
Browse files Browse the repository at this point in the history
…ameCheck
  • Loading branch information
AmitKumarDeoghoria authored and romani committed Oct 27, 2024
1 parent 309dd8c commit a4b0fc7
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ public final class InlineConfigParser {
"com.puppycrawl.tools.checkstyle.checks.naming.StaticVariableNameCheck",
"com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck",
"com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck",
"com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck",
"com.puppycrawl.tools.checkstyle.checks.regexp.RegexpMultilineCheck",
"com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck",
"com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void testOuterTypeFilenameRecords() throws Exception {
public void testOuterTypeFilenameRecordsMethodRecordDef() throws Exception {

final String[] expected = {
"10:1: " + getCheckMessage(MSG_KEY),
"11:1: " + getCheckMessage(MSG_KEY),
};
verifyWithInlineConfigParser(
getNonCompilablePath("InputOuterTypeFilenameRecord.java"), expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
//non-compiled with javac: contains different class name by demand of test
package com.puppycrawl.tools.checkstyle.checks.outertypefilename;

public record IncorrectName1(int x, int y, String str) { // violation
// violation below 'The name of the outer type and the file do not match.'
public record IncorrectName1(int x, int y, String str) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

//non-compiled with javac: contains different class name by demand of test
package com.puppycrawl.tools.checkstyle.checks.outertypefilename;

public record IncorrectName2(int x, int y, String str) { // violation
// violation below 'The name of the outer type and the file do not match.'
public record IncorrectName2(int x, int y, String str) {
class LocalRecordHelper {
Record recordMethod(int x) {
record R76 (int x) { } // Issue #8598: OuterTypeFileName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

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

class Class1 { // violation
// violation below 'The name of the outer type and the file do not match.'
class Class1 {
public interface NestedInterface {}
public enum NestedEnum {}
class NestedClass {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

// someexamples of 1.5 extensions
package com.puppycrawl.tools.checkstyle.checks.outertypefilename;
// violation below 'The name of the outer type and the file do not match.'
class InputOuterTypeFilename5NameMismatch {

class InputOuterTypeFilename5NameMismatch { // violation


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

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

class Foo {} // violation
class Foo {} // violation 'The name of the outer type and the file do not match.'
enum FooEnum {}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testExample1() throws Exception {
@Test
public void testExample2() throws Exception {
final String[] expected = {
"11:1: " + getCheckMessage(MSG_KEY),
"12:1: " + getCheckMessage(MSG_KEY),
};

verifyWithInlineConfigParser(getPath("Example2.java"), expected);
Expand All @@ -52,7 +52,7 @@ public void testExample2() throws Exception {
@Test
public void testExample3() throws Exception {
final String[] expected = {
"11:1: " + getCheckMessage(MSG_KEY),
"12:1: " + getCheckMessage(MSG_KEY),
};

verifyWithInlineConfigParser(getPath("Example3.java"), expected);
Expand All @@ -61,7 +61,7 @@ public void testExample3() throws Exception {
@Test
public void testExample4() throws Exception {
final String[] expected = {
"11:1: " + getCheckMessage(MSG_KEY),
"12:1: " + getCheckMessage(MSG_KEY),
};

verifyWithInlineConfigParser(getPath("Example4.java"), expected);
Expand All @@ -70,7 +70,7 @@ public void testExample4() throws Exception {
@Test
public void testExample5() throws Exception {
final String[] expected = {
"11:1: " + getCheckMessage(MSG_KEY),
"12:1: " + getCheckMessage(MSG_KEY),
};

verifyWithInlineConfigParser(getPath("Example5.java"), expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
package com.puppycrawl.tools.checkstyle.checks.outertypefilename;

// xdoc section -- start
class Example2ButNotSameName {} // violation
// violation below 'The name of the outer type and the file do not match.'
class Example2ButNotSameName {}
// xdoc section -- end
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
package com.puppycrawl.tools.checkstyle.checks.outertypefilename;

// xdoc section -- start
interface Example3ButNotSameName {} // violation
// violation below 'The name of the outer type and the file do not match.'
interface Example3ButNotSameName {}
// xdoc section -- end
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
package com.puppycrawl.tools.checkstyle.checks.outertypefilename;

// xdoc section -- start
enum Example4ButNotSameName {} // violation
// violation below 'The name of the outer type and the file do not match.'
enum Example4ButNotSameName {}
// xdoc section -- end
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
package com.puppycrawl.tools.checkstyle.checks.outertypefilename;

// xdoc section -- start
class Example5ButNotSameName {} // violation
// violation below 'The name of the outer type and the file do not match.'
class Example5ButNotSameName {}
// xdoc section -- end
12 changes: 8 additions & 4 deletions src/xdocs/checks/misc/outertypefilename.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,29 @@ public class Example1 {}
Example file content with name of file Example2.java
</p>
<source>
class Example2ButNotSameName {} // violation
// violation below 'The name of the outer type and the file do not match.'
class Example2ButNotSameName {}
</source>
<p id="Example3-code">
Example file content with name of file Example3.java
</p>
<source>
interface Example3ButNotSameName {} // violation
// violation below 'The name of the outer type and the file do not match.'
interface Example3ButNotSameName {}
</source>
<p id="Example4-code">
Example file content with name of file Example4.java
</p>
<source>
enum Example4ButNotSameName {} // violation
// violation below 'The name of the outer type and the file do not match.'
enum Example4ButNotSameName {}
</source>
<p id="Example5-code">
Example file content with name of file Example5.java
</p>
<source>
class Example5ButNotSameName {} // violation
// violation below 'The name of the outer type and the file do not match.'
class Example5ButNotSameName {}
</source>
</subsection>

Expand Down

0 comments on commit a4b0fc7

Please sign in to comment.