Skip to content

Commit

Permalink
Issue checkstyle#12409: Inconsistent allowedAbbreviations
Browse files Browse the repository at this point in the history
  • Loading branch information
arinmodi committed Nov 29, 2022
1 parent 13139b6 commit 0cd36a7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 33 deletions.
Expand Up @@ -304,28 +304,28 @@
* <p>Configuration:</p>
* <pre>
* &lt;module name="AbbreviationAsWordInName"&gt;
* &lt;property name="allowedAbbreviations" value="ORDER, OBSERVATION, UNDERSCORE, TEST"/&gt;
* &lt;property name="allowedAbbreviations" value="ORDER, TEST"/&gt;
* &lt;/module&gt;
* </pre>
* <p>Example:</p>
* <pre>
* public class InputAbbreviationAsWordInNameType7 {
* public class Test {
* void getTEST() {
* } // OK
*
* void getORDER_OBSERVATION() {} // OK
* void getORDER_OBSERVATION() {} // violation, at most 4 consecutive capital letters allowed
*
* void getUNDERSCORE() {} // OK
* void getUNDERSCORE() {} // violation, at most 4 consecutive capital letters allowed
*
* void getTEST_OBSERVATION() {} // OK
* void getTEST_OBSERVATION() {} // violation, at most 4 consecutive capital letters allowed
*
* void getTEST_UNDERSCORE() {} // OK
* void getTEST_UNDERSCORE() {} // violation, at most 4 consecutive capital letters allowed
*
* void getORDER() {} // OK
*
* void getOBSERVATION() {} // OK
* void getOBSERVATION() {} // violation, at most 4 consecutive capital letters allowed
*
* void getORDER_UNDERSCORE() {} // OK
* void getORDER_UNDERSCORE() {} // violation, at most 4 consecutive capital letters allowed
* }
* </pre>
* <p>
Expand Down
Expand Up @@ -468,12 +468,13 @@ public void testReceiver() throws Exception {
}

@Test
public void demoTest() throws Exception {
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
public void testInputAbbreviationAsWordInNameTypeWithUnderScore() throws Exception {
final String[] expected = {
"14:10: " + getWarningMessage("getNONE_Test", 4),
};

verifyWithInlineConfigParser(
getPath("InputAbbreviationAsWordInNameType7.java"),
expected);
getPath("InputAbbreviationAsWordInNameType7.java"), expected);
}

}
Expand Up @@ -9,20 +9,9 @@
package com.puppycrawl.tools.checkstyle.checks.naming.abbreviationaswordinname;

public class InputAbbreviationAsWordInNameType7 {
void getTEST() {
} // OK

void getORDER_OBSERVATION() {} // ok

void getUNDERSCORE() {} // ok

void getTEST_OBSERVATION() {} // ok

void getTEST_UNDERSCORE() {} // ok

void getORDER() {} // ok

void getOBSERVATION() {} // ok
void getNONE_Test() {} // violation

void getORDER_UNDERSCORE() {} // ok
void getCLR_Test() {} // ok
}
16 changes: 8 additions & 8 deletions src/xdocs/config_naming.xml
Expand Up @@ -354,28 +354,28 @@ public class MyClass {
<p>Configuration:</p>
<source>
&lt;module name="AbbreviationAsWordInName"&gt;
&lt;property name="allowedAbbreviations" value="ORDER, OBSERVATION, UNDERSCORE, TEST"/&gt;
&lt;property name="allowedAbbreviations" value="ORDER, TEST"/&gt;
&lt;/module&gt;
</source>
<p>Example:</p>
<source>
public class InputAbbreviationAsWordInNameType7 {
public class Test {
void getTEST() {
} // OK

void getORDER_OBSERVATION() {} // OK
void getORDER_OBSERVATION() {} // violation, at most 4 consecutive capital letters allowed

void getUNDERSCORE() {} // OK
void getUNDERSCORE() {} // violation, at most 4 consecutive capital letters allowed

void getTEST_OBSERVATION() {} // OK
void getTEST_OBSERVATION() {} // violation, at most 4 consecutive capital letters allowed

void getTEST_UNDERSCORE() {} // OK
void getTEST_UNDERSCORE() {} // violation, at most 4 consecutive capital letters allowed

void getORDER() {} // OK

void getOBSERVATION() {} // OK
void getOBSERVATION() {} // violation, at most 4 consecutive capital letters allowed

void getORDER_UNDERSCORE() {} // OK
void getORDER_UNDERSCORE() {} // violation, at most 4 consecutive capital letters allowed
}
</source>
</subsection>
Expand Down

0 comments on commit 0cd36a7

Please sign in to comment.