Skip to content

Commit

Permalink
Issue checkstyle#4141: Split and Organize Checkstyle inputs by Test f…
Browse files Browse the repository at this point in the history
…or ConstantName
  • Loading branch information
Kietzmann committed Apr 24, 2017
1 parent 8971090 commit 3335dfa
Show file tree
Hide file tree
Showing 7 changed files with 407 additions and 18 deletions.
Expand Up @@ -41,7 +41,9 @@ public class ConstantNameCheckTest
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "naming" + File.separator + filename);
+ "naming" + File.separator
+ "constantname" + File.separator
+ filename);
}

@Override
Expand Down Expand Up @@ -88,7 +90,7 @@ public void testDefault()
"25:29: " + getCheckMessage(MSG_INVALID_PATTERN, "badConstant", pattern),
"142:30: " + getCheckMessage(MSG_INVALID_PATTERN, "BAD__NAME", pattern),
};
verify(checkConfig, getPath("InputSimple.java"), expected);
verify(checkConfig, getPath("InputConstantNameSimple.java"), expected);
}

@Test
Expand All @@ -105,7 +107,7 @@ public void testAccessControlTuning()
final String[] expected = {
"142:30: " + getCheckMessage(MSG_INVALID_PATTERN, "BAD__NAME", pattern),
};
verify(checkConfig, getPath("InputSimple.java"), expected);
verify(checkConfig, getPath("InputConstantNameSimple.java"), expected);
}

@Test
Expand All @@ -120,7 +122,7 @@ public void testInterfaceAndAnnotation()
"24:16: " + getCheckMessage(MSG_INVALID_PATTERN, "data", pattern),
"64:16: " + getCheckMessage(MSG_INVALID_PATTERN, "data", pattern),
};
verify(checkConfig, getPath("InputInner.java"), expected);
verify(checkConfig, getPath("InputConstantNameInner.java"), expected);
}

@Test
Expand Down Expand Up @@ -149,7 +151,7 @@ public void testIntoInterface() throws Exception {
"52:9: " + getCheckMessage(MSG_INVALID_PATTERN, "_package", pattern),
"53:9: " + getCheckMessage(MSG_INVALID_PATTERN, "_private", pattern),
};
verify(checkConfig, getPath("InputMemberNameExtended.java"), expected);
verify(checkConfig, getPath("InputConstantNameMemberExtended.java"), expected);
}

@Test
Expand All @@ -158,7 +160,7 @@ public void testStaticMethodInInterface()
final DefaultConfiguration checkConfig =
createCheckConfig(ConstantNameCheck.class);
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
verify(checkConfig, getPath("InputStaticModifierInInterface.java"), expected);
verify(checkConfig, getPath("InputConstantNameStaticModifierInInterface.java"), expected);
}

@Test
Expand Down

This file was deleted.

@@ -0,0 +1,79 @@
////////////////////////////////////////////////////////////////////////////////
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.naming.constantname;

/**
* Tests having inner types
* @author Oliver Burn
**/
class InputConstantNameInner
{
// Ignore - two errors
class InnerInner2
{
// Ignore
public int fData;
}

// Ignore - 2 errors
interface InnerInterface2
{
// Ignore - should be all upper case
String data = "zxzc";

// Ignore
class InnerInterfaceInnerClass
{
// Ignore - need Javadoc and made private
public int rData;

/** needs to be made private unless allowProtected. */
protected int protectedVariable;

/** needs to be made private unless allowPackage. */
int packageVariable;
}
}

/** demonstrate bug in handling static final **/
protected static Object sWeird = new Object();
/** demonstrate bug in handling static final **/
static Object sWeird2 = new Object();

/** demonstrate bug in local final variable */
public interface Inter
{
}

public static void main()
{
Inter m = new Inter()
{
private static final int CDS = 1;

private int ABC;
};
}

/** annotation field incorrectly named. */
@interface InnerAnnotation
{
/** Ignore - should be all upper case. */
String data = "zxzc";
}

/** enum with public member variable */
enum InnerEnum
{
/** First constant */
A,

/** Second constant */
B;

/** Should be private */
public int someValue;
}
}
@@ -0,0 +1,83 @@
package com.puppycrawl.tools.checkstyle.checks.naming.constantname;




public class InputConstantNameMemberExtended
{
public int mPublic;
protected int mProtected;
int mPackage;
private int mPrivate;

public int _public;
protected int _protected;
int _package;
private int _private;

class Inner {
public int mPublic;
protected int mProtected;
int mPackage;
private int mPrivate;

public int _public;
protected int _protected;
int _package;
private int _private;
}

Inner anon = new Inner() {
public int mPublic;
protected int mProtected;
int mPackage;
private int mPrivate;

public int _public;
protected int _protected;
int _package;
private int _private;
};
}

interface In
{
public int mPublic = 0;
int mProtected = 0;
int mPackage = 0;
int mPrivate = 0;

public int _public = 0;
int _protected = 0;
int _package = 0;
int _private = 0;
}

enum Direction {

NORTH(1),
SOUTH(-1),
EAST(-2),
WEST(2);

public int mPublic = 0;
int mProtected = 0;
int mPackage = 0;
int mPrivate = 0;

public int _public = 0;
int _protected = 0;
int _package = 0;
int _private = 0;

Direction(int code){
this.code=code;
}
protected int code;
public int getCode() {
return this.code;
}
static Direction getOppositeDirection(Direction d){
return null;
}
}

0 comments on commit 3335dfa

Please sign in to comment.