Skip to content

Commit

Permalink
Issue checkstyle#10548: Migrate to Inline Config Parser in ArrayTrail…
Browse files Browse the repository at this point in the history
…ingCommaCheckTest
  • Loading branch information
shashwatj07 committed Aug 5, 2021
1 parent c350a32 commit 7ef53e3
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 44 deletions.
1 change: 0 additions & 1 deletion pom.xml
Expand Up @@ -1706,7 +1706,6 @@

<exclude>**/NoWhitespaceAfterCheckTest.class</exclude>

<exclude>**/ArrayTrailingCommaCheckTest.class</exclude>

<exclude>**/HideUtilityClassConstructorCheckTest.class</exclude>

Expand Down
Expand Up @@ -40,7 +40,7 @@ public final class InlineConfigParser {

/** A pattern to find the string: "// violation". */
private static final Pattern VIOLATION_PATTERN = Pattern
.compile(".*//\\s*violation(?:\\W+(.*))?$");
.compile(".*//\\s*violation(?:\\W+\'(.*)\')?$");

/** Stop instances being created. **/
private InlineConfigParser() {
Expand Down
Expand Up @@ -46,7 +46,8 @@ public void testDefault()
"80:9: " + getCheckMessage(MSG_KEY),
"82:12: " + getCheckMessage(MSG_KEY),
};
verify(checkConfig, getPath("InputArrayTrailingComma.java"), expected);
verifyWithInlineConfigParser(checkConfig,
getPath("InputArrayTrailingComma.java"), expected);
}

@Test
Expand Down Expand Up @@ -74,7 +75,7 @@ public void testAlwaysDemandTrailingComma() throws Exception {
"54:17: " + getCheckMessage(MSG_KEY),
"56:13: " + getCheckMessage(MSG_KEY),
};
verify(checkConfig,
verifyWithInlineConfigParser(checkConfig,
getPath("InputArrayTrailingCommaAlwaysDemandTrailingComma.java"), expected);
}

Expand Down
Expand Up @@ -14,13 +14,13 @@ public class InputMissingOverrideBadAnnotation
/**
* {@inheritDoc}
*/
public void run() { // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void run() { // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
Throwable t = new Throwable() {

/**
* {@inheritDoc}
*/
public String toString() { // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public String toString() { // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
return "junk";
}
};
Expand All @@ -33,13 +33,13 @@ void doFoo(Runnable r) {
/**
* {@inheritDoc}
*/
public void run() { // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void run() { // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
Throwable t = new Throwable() {

/**
* {@inheritDoc}
*/
public String toString() { // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public String toString() { // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
return "junk";
}
};
Expand Down
Expand Up @@ -12,7 +12,7 @@ public class InputMissingOverrideBadOverrideFromObject
/**
* {@inheritDoc}
*/
public boolean equals(Object obj) { // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public boolean equals(Object obj) { // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
return false;
}

Expand All @@ -32,7 +32,7 @@ class Junk {
/**
* {@inheritDoc}
*/
protected void finalize() throws Throwable {} // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
protected void finalize() throws Throwable {} // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
}
}

Expand All @@ -41,7 +41,7 @@ interface HashEq2 {
/**
* {@inheritDoc}
*/
public int hashCode(); // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public int hashCode(); // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
}

enum enum3 {
Expand All @@ -50,7 +50,7 @@ enum enum3 {
/**
* {@inheritDoc}
*/
public String toString() { // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public String toString() { // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
return "B";
}

Expand Down
Expand Up @@ -12,7 +12,7 @@ public class InputMissingOverrideBadOverrideFromObjectJava5
/**
* {@inheritDoc}
*/
public boolean equals(Object obj) { // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public boolean equals(Object obj) { // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
return false;
}

Expand All @@ -32,7 +32,7 @@ class Junk {
/**
* {@inheritDoc}
*/
protected void finalize() throws Throwable {} // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
protected void finalize() throws Throwable {} // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
}
}

Expand All @@ -41,7 +41,7 @@ interface HashEq2Java5 {
/**
* {@inheritDoc}
*/
public int hashCode(); // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public int hashCode(); // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
}

enum enum3Java5 {
Expand All @@ -50,7 +50,7 @@ enum enum3Java5 {
/**
* {@inheritDoc}
*/
public String toString() { // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public String toString() { // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
return "B";
}

Expand Down
Expand Up @@ -14,7 +14,7 @@ public class InputMissingOverrideBadOverrideFromOther implements IFoo2
/**
* {@inheritDoc}
*/
public void doFoo() {} // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void doFoo() {} // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'

public void doFoo2() {}

Expand All @@ -30,32 +30,32 @@ interface IBar2 extends IFoo2 {
/**
* {@inheritDoc}
*/
public void doFoo(); // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void doFoo(); // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
}

class MoreJunk2 extends InputMissingOverrideBadOverrideFromOther {

/**
* {@inheritDoc}
*/
public void doFoo() {} // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void doFoo() {} // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'

/**
* {@inheritDoc}
*/
public void doFoo2() {} // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void doFoo2() {} // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'

class EvenMoreJunk extends MoreJunk2 implements Serializable {

/**
* {@inheritDoc}
*/
public void doFoo() {} // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void doFoo() {} // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'

/**
* {@inheritDoc}
*/
public void doFoo2() {} // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void doFoo2() {} // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
}
}

Expand All @@ -65,5 +65,5 @@ enum Football2 implements IFoo2, IBar2 {
/**
* {@inheritDoc}
*/
public void doFoo() {} // violation Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.
public void doFoo() {} // violation 'Must include @java.lang.Override annotation when {@inheritDoc} Javadoc tag exists.'
}
Expand Up @@ -12,12 +12,12 @@ public class InputMissingOverrideNotOverride
/**
* {@inheritDoc}
*/
private void bleh() {} // violation The Javadoc {@inheritDoc} tag is not valid at this location.
private void bleh() {} // violation 'The Javadoc {@inheritDoc} tag is not valid at this location.'

/**
* {@inheritDoc}
*/
public static void eh() {} // violation The Javadoc {@inheritDoc} tag is not valid at this location.
public static void eh() {} // violation 'The Javadoc {@inheritDoc} tag is not valid at this location.'

/**
* {@inheritDoc}
Expand Down
Expand Up @@ -20,7 +20,7 @@ public class InputArrayTrailingComma
{
1,
2,
3 // violation
3 // violation 'Array should contain trailing comma.'
};

int[] b1 = new int[] {1, 2, 3,};
Expand All @@ -40,7 +40,7 @@ public class InputArrayTrailingComma
{1,
2},
{3, 3,},
{5, 6,} // violation
{5, 6,} // violation 'Array should contain trailing comma.'
};

int[] e1 = new int[] {
Expand Down Expand Up @@ -77,8 +77,8 @@ public class InputArrayTrailingComma
Object[][] g2 = new Object[][]
{
{ 1, 1 },
{
{ // violation 'Array should contain trailing comma.'
null,
new int[] { 2,
3 } } }; // violation
new int[] { 2, // violation 'Array should contain trailing comma.'
3 } } };
}
Expand Up @@ -12,48 +12,48 @@ public int[] test() {
if (true) {
return new int[]{0,};
}
return new int[]{0}; // violation
return new int[]{0}; // violation 'Array should contain trailing comma.'
}

public int[] test2() {
if (true) {
return new int[]{0, 1,};
}
return new int[]{0, 1}; // violation
return new int[]{0, 1}; // violation 'Array should contain trailing comma.'
}

public void test3() {
int[] a = new int[]
{0}; // violation
{0}; // violation 'Array should contain trailing comma.'
int[] b = new int[]
{0, 1}; // violation
{0, 1}; // violation 'Array should contain trailing comma.'
int[] c = new int[]
{0, 1,
2, 3
}; // violation
2, 3 // violation 'Array should contain trailing comma.'
};
int[] d = new int[]
{
1,
2,
3
}; // violation
3 // violation 'Array should contain trailing comma.'
};
int[] e = new int[]
{
1,
5,
6,
};
int[] f = {1,
2
}; // violation
2 // violation 'Array should contain trailing comma.'
};
int[] g = {1,
2,
};
int[][] empty2d = {{}}; // violation
int[][] empty2d = {{}}; // violation 'Array should contain trailing comma.'
int[][] multiDimensionalArray = {
{1, 2}, // violation
{1, 2}, // violation 'Array should contain trailing comma.'
{1,},
{3, 2, 1,}
}; // violation
{3, 2, 1,} // violation 'Array should contain trailing comma.'
};
}
}

0 comments on commit 7ef53e3

Please sign in to comment.