forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#15004: Add input file for record pattern syntax in A…
…bbreviationAsWordInName
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...cks/naming/abbreviationaswordinname/InputAbbreviationAsWordInNameCheckRecordPatterns.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
AbbreviationAsWordInName | ||
allowedAbbreviationLength = (default)3 | ||
allowedAbbreviations = (default) | ||
ignoreFinal = (default)true | ||
ignoreStatic = (default)true | ||
ignoreStaticFinal = (default)true | ||
ignoreOverriddenMethods = (default)true | ||
tokens = (default)CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, \ | ||
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, \ | ||
RECORD_COMPONENT_DEF | ||
*/ | ||
|
||
//non-compiled with javac: Compilable with Java21 | ||
package com.puppycrawl.tools.checkstyle.checks.naming.abbreviationaswordinname; | ||
|
||
public class InputAbbreviationAsWordInNameCheckRecordPatterns { | ||
|
||
void m(Object o) { | ||
// violation below, 'Abbreviation in name 'POINT'*.' | ||
if (o instanceof ColoredPoint POINT) { | ||
|
||
} | ||
// violation below, 'Abbreviation in name 'COLOR'*.' | ||
if (o instanceof ColoredPoint(int x, int y, String COLOR)) { | ||
|
||
} | ||
|
||
if (o instanceof Rectangle(ColoredPoint(int INTEGER,_, String STRING),ColoredPoint _)) {} | ||
// 2 violations above: | ||
// 'Abbreviation in name 'INTEGER'*.' | ||
// 'Abbreviation in name 'STRING'*.' | ||
} | ||
void m2(Object o) { | ||
switch (o) { | ||
// violation below, 'Abbreviation in name 'COLOR'*.' | ||
case ColoredPoint(int x, int y, String COLOR) -> {} | ||
case Rectangle(ColoredPoint(int x, int INTEGER, String COLOR), _) -> {} | ||
// 2 violations above: | ||
// 'Abbreviation in name 'INTEGER'*.' | ||
// 'Abbreviation in name 'COLOR'*.' | ||
default -> {} | ||
} | ||
} | ||
|
||
|
||
record ColoredPoint(int x, int y, String color) {} | ||
record Rectangle(ColoredPoint upperLeft, ColoredPoint lowerRight) {} | ||
} |