Some changes to testinputs to make them compilable (not completed for
now). Also, I've removed test for SuperFinalize check which tests finalize() method in enums, since enums can not have this method.
This commit is contained in:
parent
9a15d83aa7
commit
be3f6d793c
|
|
@ -180,9 +180,9 @@
|
|||
<mkdir dir="target/testinputs" />
|
||||
<depend srcdir="src/testinputs" destdir="target/testinputs" closure="yes"/>
|
||||
<!-- start of a change to turn on compilation of all input files -->
|
||||
<!-- under JDK1.4. -->
|
||||
<!-- under JDK1.5. -->
|
||||
<property name="testExcludes"
|
||||
value="**/InputWhitespace.java,**/InputImport.java"/>
|
||||
value="**/grammars/*,**/j2ee/*,**/InputAssertIdentifier.java,**/InputSimple.java,**/InputTags.java,**/InputJUnitTest.java,**/InputValidMethodIndent.java,**/InputSetterGetter.java,**/InputImport.java,**/InputUnusedMethod.java"/>
|
||||
<javac srcdir="src/testinputs"
|
||||
destdir="target/testinputs"
|
||||
deprecation="on" debug="on"
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public class InputArrayTypeStyle
|
|||
|
||||
public Test[] getNewTest()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package com.puppycrawl.tools.checkstyle;
|
|||
* Test case for the "design for inheritance" check.
|
||||
* @author Lars Kühne
|
||||
**/
|
||||
public class InputDesignForExtension
|
||||
public abstract class InputDesignForExtension
|
||||
{
|
||||
// some methods that are OK
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class InputDoubleCheckedLocking
|
|||
{
|
||||
synchronized (InputDoubleCheckedLocking.class)
|
||||
{
|
||||
if (one == "one")
|
||||
if (one == Integer.valueOf(2))
|
||||
{
|
||||
one = new Integer(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ public class InputEmptyStatement
|
|||
;
|
||||
}
|
||||
|
||||
public void EmptyStatements()
|
||||
public void EmptyStatements(boolean cond)
|
||||
{
|
||||
for (;;);
|
||||
for (;cond;);
|
||||
|
||||
for (;;)
|
||||
for (;cond;)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ public class InputEmptyStatement
|
|||
;
|
||||
}
|
||||
|
||||
if (true)
|
||||
if (cond)
|
||||
{
|
||||
int i;
|
||||
}
|
||||
|
|
@ -51,21 +51,21 @@ public class InputEmptyStatement
|
|||
;
|
||||
}
|
||||
|
||||
while (true);
|
||||
while (cond);
|
||||
|
||||
while (true)
|
||||
while (cond)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
do;
|
||||
while (true);
|
||||
while (cond);
|
||||
|
||||
do
|
||||
{
|
||||
;
|
||||
}
|
||||
while (true);
|
||||
while (cond);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ abstract class Operation2 implements Evaluatable
|
|||
public static final Operation2 PLUS =
|
||||
new Operation2("+")
|
||||
{
|
||||
double eval(double a, double b)
|
||||
public double eval(double a, double b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ abstract class Operation2 implements Evaluatable
|
|||
public static final Operation2 MINUS =
|
||||
new Operation2("-")
|
||||
{
|
||||
double eval(double a, double b)
|
||||
public double eval(double a, double b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
|
@ -110,4 +110,4 @@ enum testenum2
|
|||
{
|
||||
private someinnerClass() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import java.awt.event.Actionevent;
|
||||
import javax.swing.Action;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
/**
|
||||
* Test case for detecting missing final parameters.
|
||||
|
|
@ -86,7 +87,7 @@ class InputFinalParameters
|
|||
{
|
||||
Action a = new AbstractAction()
|
||||
{
|
||||
void actionPerformed(ActionEvent e)
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
}
|
||||
void somethingElse(@MyAnnotation ActionEvent e)
|
||||
|
|
@ -96,7 +97,7 @@ class InputFinalParameters
|
|||
|
||||
Action b = new AbstractAction()
|
||||
{
|
||||
void actionPerformed(final ActionEvent e)
|
||||
public void actionPerformed(final ActionEvent e)
|
||||
{
|
||||
}
|
||||
void somethingElse(@MyAnnotation final ActionEvent e)
|
||||
|
|
@ -121,16 +122,16 @@ class InputFinalParameters
|
|||
try {
|
||||
System.err.println("");
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (java.lang.NullPointerException npe) {
|
||||
npe.printStackTrace();
|
||||
}
|
||||
catch (@MyAnnotation NoClassDefFoundError e) {
|
||||
catch (@MyAnnotation final ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (@MyAnnotation final ClassCastException e) {
|
||||
catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (@MyAnnotation NoClassDefFoundError e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
@ -163,4 +164,12 @@ class Foo
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
private String[] someExpression()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@interface MyAnnotation {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,3 +11,9 @@ public class InputGenerics<A, B extends Collection<?>, C extends D&E>
|
|||
class BadCommas < A,B,C extends Map < A,String > >
|
||||
{
|
||||
}
|
||||
|
||||
// we need these interfaces for generics
|
||||
interface D {
|
||||
}
|
||||
interface E {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ class StaticMethods
|
|||
void useX(int x) {
|
||||
x++;
|
||||
}
|
||||
void useX(int y) {
|
||||
void useY(int y) {
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ interface NothingHiddenReorder
|
|||
public void noShadow(int notHidden);
|
||||
}
|
||||
|
||||
enum HiddenEnum
|
||||
enum HiddenEnum1
|
||||
{
|
||||
A(129),
|
||||
B(283),
|
||||
|
|
@ -115,7 +115,7 @@ enum HiddenEnum
|
|||
/**
|
||||
* ctor parameter hides member
|
||||
*/
|
||||
HiddenEnum(int hidden)
|
||||
HiddenEnum1(int hidden)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -133,4 +133,4 @@ enum HiddenEnum
|
|||
|
||||
int hidden;
|
||||
static int hiddenStatic;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class InputLeftCurlyOther
|
|||
}
|
||||
|
||||
// test input for bug reported by Joe Comuzzi
|
||||
if (System.currentMillis() > 1000)
|
||||
if (System.currentTimeMillis() > 1000)
|
||||
return 1;
|
||||
else
|
||||
return 2;
|
||||
|
|
@ -80,9 +80,8 @@ class InputLeftCurlyOther
|
|||
|
||||
|
||||
public enum GreetingsEnum
|
||||
{
|
||||
HELLO,
|
||||
{
|
||||
HELLO,
|
||||
GOODBYE
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class ComplexButNotFlagged
|
|||
// (at least in the default configuration of MagicNumberCheck)
|
||||
public static final Integer DEFAULT_INT = new Integer(27);
|
||||
public static final int SECS_PER_DAY = 24 * 60 * 60;
|
||||
public static final javax.swing.Border STD_BORDER =
|
||||
public static final javax.swing.border.Border STD_BORDER =
|
||||
javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
public class test {
|
||||
public class InputMissingSwitchDefault {
|
||||
public void foo() {
|
||||
int i = 1;
|
||||
switch (i) {
|
||||
|
|
|
|||
|
|
@ -63,16 +63,16 @@ strictfp final class InputModifier // illegal order of modifiers for class
|
|||
abstract void c();
|
||||
|
||||
/** redundant 'public' modifier */
|
||||
public float PI_PUBLIC = 3.14;
|
||||
public float PI_PUBLIC = (float) 3.14;
|
||||
|
||||
/** redundant 'abstract' modifier */
|
||||
abstract float PI_ABSTRACT = 3.14;
|
||||
/** redundant 'abstract' modifier (field can not be absract)*/
|
||||
// abstract float PI_ABSTRACT = (float) 3.14;
|
||||
|
||||
/** redundant 'final' modifier */
|
||||
final float PI_FINAL = 3.14;
|
||||
final float PI_FINAL = (float) 3.14;
|
||||
|
||||
/** all OK */
|
||||
float PI_OK = 3.14;
|
||||
float PI_OK = (float) 3.14;
|
||||
}
|
||||
|
||||
/** redundant 'final' modifier */
|
||||
|
|
@ -120,3 +120,6 @@ interface InnerImplementation
|
|||
public String blah();
|
||||
abstract String blah2();
|
||||
}
|
||||
|
||||
@interface MyAnnotation2 {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ class InputNestedBlocks
|
|||
|
||||
// if (condition that is not important anymore)
|
||||
{ // nested block, should be marked
|
||||
int x = 1;
|
||||
int y = x;
|
||||
int z = 1;
|
||||
int y = z;
|
||||
}
|
||||
|
||||
if (x == 1)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@ package com.puppycrawl.tools.checkstyle;
|
|||
* NewlineAtEndOfFileCheck.
|
||||
* @author Christopher Lenz
|
||||
**/
|
||||
public interface InputNoNewlineAtEndOfFile
|
||||
public interface InputNewlineAtEndOfFile
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class InputSimple2
|
|||
}
|
||||
|
||||
/** Test enum for member naming check */
|
||||
enum MyEnum
|
||||
enum MyEnum1
|
||||
{
|
||||
/** ABC constant */
|
||||
ABC,
|
||||
|
|
@ -222,4 +222,4 @@ enum MyEnum
|
|||
|
||||
/** Should be mSomeMemeber */
|
||||
private int someMember;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
package com.puppycrawl.tools.checkstyle;
|
||||
import java.io.IOException;
|
||||
// Tests for Javadoc tags.
|
||||
class InputTags
|
||||
class InputTags1
|
||||
{
|
||||
// Invalid - should be Javadoc
|
||||
private int mMissingJavadoc;
|
||||
|
|
@ -293,7 +293,7 @@ class InputTags
|
|||
*
|
||||
* @return 1
|
||||
*/
|
||||
public int foo(Bar _arg) {
|
||||
public int foo(Object _arg) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -337,12 +337,12 @@ enum InputTagsEnum
|
|||
/**
|
||||
* Some javadoc.
|
||||
*/
|
||||
public class MyClass {
|
||||
public class InputTags {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public MyClass() {
|
||||
public InputTags() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class Main
|
|||
}
|
||||
}
|
||||
|
||||
class test1
|
||||
class UncommentedMainTest1
|
||||
{
|
||||
// one more uncommented main
|
||||
public static void main(java.lang.String[] args)
|
||||
|
|
@ -35,7 +35,7 @@ class test1
|
|||
}
|
||||
}
|
||||
|
||||
class test2
|
||||
class UncommentedMainTest2
|
||||
{
|
||||
// wrong arg type
|
||||
public static void main(int args)
|
||||
|
|
@ -44,7 +44,7 @@ class test2
|
|||
}
|
||||
}
|
||||
|
||||
class test3
|
||||
class UncommentedMainTest3
|
||||
{
|
||||
// no-public main
|
||||
static void main(String[] args)
|
||||
|
|
@ -53,7 +53,7 @@ class test3
|
|||
}
|
||||
}
|
||||
|
||||
class test4
|
||||
class UncommentedMainTest4
|
||||
{
|
||||
// non-static main
|
||||
public void main(String[] args)
|
||||
|
|
@ -62,7 +62,7 @@ class test4
|
|||
}
|
||||
}
|
||||
|
||||
class test5
|
||||
class UncommentedMainTest5
|
||||
{
|
||||
// wrong return type
|
||||
public static int main(String[] args)
|
||||
|
|
@ -72,7 +72,7 @@ class test5
|
|||
}
|
||||
}
|
||||
|
||||
class test6
|
||||
class UncommentedMainTest6
|
||||
{
|
||||
// too many params
|
||||
public static void main(String[] args, int param)
|
||||
|
|
@ -81,7 +81,7 @@ class test6
|
|||
}
|
||||
}
|
||||
|
||||
class test7
|
||||
class UncommentedMainTest7
|
||||
{
|
||||
// main w/o params
|
||||
public static void main()
|
||||
|
|
|
|||
|
|
@ -196,6 +196,9 @@ class InputWhitespace
|
|||
// ^ whitespace
|
||||
};
|
||||
}
|
||||
|
||||
void doStuff() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -233,4 +236,8 @@ class SpecialCasesInForLoop
|
|||
//Should be ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int[] getSomeInts() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class InputDeclarationOrder
|
|||
// error ctors before methods
|
||||
public InputDeclarationOrder()
|
||||
{
|
||||
final String foo = ERROR;
|
||||
String foo = ERROR;
|
||||
foo += ERROR1;
|
||||
foo += WARNING;
|
||||
int fooInt = mMaxInitVars;
|
||||
|
|
@ -63,7 +63,7 @@ public class InputDeclarationOrder
|
|||
|
||||
public static int getFoo2()
|
||||
{
|
||||
return mFoo;
|
||||
return 13;
|
||||
}
|
||||
|
||||
public int getFoo()
|
||||
|
|
@ -71,9 +71,9 @@ public class InputDeclarationOrder
|
|||
return mFoo;
|
||||
}
|
||||
|
||||
private static int getFoo2()
|
||||
private static int getFoo21()
|
||||
{
|
||||
return mFoo;
|
||||
return 14;
|
||||
}
|
||||
|
||||
// error member variables should be before methods or ctors
|
||||
|
|
@ -151,7 +151,7 @@ enum InputDeclarationOrderEnum
|
|||
// error ctors before methods
|
||||
InputDeclarationOrderEnum()
|
||||
{
|
||||
final String foo = ERROR;
|
||||
String foo = ERROR;
|
||||
foo += ERROR1;
|
||||
foo += WARNING;
|
||||
int fooInt = mMaxInitVars;
|
||||
|
|
@ -161,7 +161,7 @@ enum InputDeclarationOrderEnum
|
|||
|
||||
public static int getFoo2()
|
||||
{
|
||||
return mFoo;
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int getFoo()
|
||||
|
|
@ -169,11 +169,11 @@ enum InputDeclarationOrderEnum
|
|||
return mFoo;
|
||||
}
|
||||
|
||||
private static int getFoo2()
|
||||
private static int getFoo21()
|
||||
{
|
||||
return mFoo;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// error member variables should be before methods or ctors
|
||||
private int mFoo = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
public class InputExplicitInit {
|
||||
private int x = 0;
|
||||
private Bar bar = null;
|
||||
private Object bar = null;
|
||||
private int y = 1;
|
||||
private long y1 = 1 - 1;
|
||||
private long y3;
|
||||
|
|
@ -23,7 +23,7 @@ public class InputExplicitInit {
|
|||
|
||||
void method() {
|
||||
int xx = 0;
|
||||
Strign s = null;
|
||||
String s = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
public class InputFallThrough
|
||||
{
|
||||
void method(int i, int j) {
|
||||
void method(int i, int j, boolean cond) {
|
||||
while (true) {
|
||||
switch (i) {
|
||||
case 0: // no problem
|
||||
|
|
@ -54,7 +54,7 @@ public class InputFallThrough
|
|||
return;
|
||||
} while(true);
|
||||
case 16:
|
||||
for (int j = 0; j < 10; j++) {
|
||||
for (int j1 = 0; j1 < 10; j1++) {
|
||||
System.err.println("something");
|
||||
return;
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ public class InputFallThrough
|
|||
while (true)
|
||||
throw new RuntimeException("");
|
||||
case 18:
|
||||
while(false) {
|
||||
while(cond) {
|
||||
break;
|
||||
}
|
||||
case 19: //fall through!!!
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ public class InputFinalLocalVariable
|
|||
public void run()
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public InputFinalLocalVariable()
|
||||
{
|
||||
int i = 0;
|
||||
|
|
@ -39,7 +39,7 @@ public class InputFinalLocalVariable
|
|||
{
|
||||
int q = 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public void method(int aArg, final int aFinal, int aArg2)
|
||||
|
|
@ -77,7 +77,7 @@ public class InputFinalLocalVariable
|
|||
public void run()
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ public class InputFinalLocalVariable
|
|||
k++;
|
||||
aBool = false;
|
||||
}
|
||||
|
||||
|
||||
int l = 0;
|
||||
{
|
||||
int weird = 0;
|
||||
|
|
@ -131,9 +131,13 @@ class Blah
|
|||
{
|
||||
static
|
||||
{
|
||||
for(int a : some.getInts())
|
||||
for(int a : getInts())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static int[] getInts() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,21 +42,3 @@ class InnerFinalize
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum MyEnum
|
||||
{
|
||||
; //No constants, just for the fun of it
|
||||
public void finalize() throws Throwable
|
||||
{
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
enum MyEnum2
|
||||
{
|
||||
; //No constants, just for the fun of it
|
||||
public void finalize() throws Throwable
|
||||
{
|
||||
//No super.finalize()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks.coding;
|
||||
|
||||
import java.util.HashTable;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class InputIllegalType {
|
||||
private AbstractClass a = null;
|
||||
private NotAnAbstractClass b = null;
|
||||
|
||||
private au.com.redhillconsulting.jamaica.tools.checkstyle.InputIllegalType.AbstractClass c = null;
|
||||
private au.com.redhillconsulting.jamaica.tools.checkstyle.InputIllegalType.NotAnAbstractClass d = null;
|
||||
private com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass c = null;
|
||||
private com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.NotAnAbstractClass d = null;
|
||||
|
||||
private abstract class AbstractClass {}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// Created: 2003
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.puppycrawl.tools.checkstyle;
|
||||
|
||||
import java.io.Serializable;
|
||||
class InputModifiedControl
|
||||
{
|
||||
int k;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ public class InputMultipleVariableDeclarations
|
|||
strings[];
|
||||
//both definitions is wrapped
|
||||
java.lang.
|
||||
String string; java.lang.String
|
||||
strings[];
|
||||
String string1; java.lang.String
|
||||
strings1[];
|
||||
|
||||
void method2() {
|
||||
for (int i=0, j=0; i < 10; i++, j--) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,6 @@ public class InputParameterAssignment {
|
|||
}
|
||||
|
||||
void foo3(String field, int field1) {
|
||||
this.field = (field1 += field.length);
|
||||
this.field = (field1 += field.length());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ public class InputRequireThis {
|
|||
i++;
|
||||
this.i = i;
|
||||
method1();
|
||||
j--; // unhandled for now
|
||||
try {
|
||||
this.method1();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.puppycrawl.tools.checkstyle.coding;
|
||||
|
||||
public class ReturnFromCatchCheckTestInput {
|
||||
public class InputReturnFromCatchCheck {
|
||||
public void foo() {
|
||||
try {
|
||||
System.currentTimeMillis();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.puppycrawl.tools.checkstyle.coding;
|
||||
|
||||
public class ReturnFromFinallyCheckTestInput {
|
||||
public class InputReturnFromFinallyCheck {
|
||||
public void foo() {
|
||||
try {
|
||||
System.currentTimeMillis();
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ public class InputInvalidAssignIndent
|
|||
String line = mIndentCheck[
|
||||
getLineNo()];
|
||||
String line1 =
|
||||
getLineNo();
|
||||
getLine();
|
||||
line1 =
|
||||
getLineNo();
|
||||
getLine();
|
||||
int i
|
||||
=
|
||||
1;
|
||||
|
|
@ -17,4 +17,11 @@ public class InputInvalidAssignIndent
|
|||
// TODO: add more testing
|
||||
}
|
||||
|
||||
private String[] mIndentCheck = null;
|
||||
int getLineNo() {
|
||||
return 1;
|
||||
}
|
||||
String getLine() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
package com.puppycrawl.tools.checkstyle.indentation;
|
||||
|
||||
import java.util.Arrays;
|
||||
/**
|
||||
*
|
||||
* @author jrichard
|
||||
|
|
@ -116,7 +116,7 @@ public class InputInvalidMethodIndent {
|
|||
new String("type"));
|
||||
|
||||
|
||||
String blah = (String) System.getProperty(
|
||||
String blah1 = (String) System.getProperty(
|
||||
new String("type")
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ package com.puppycrawl.tools.checkstyle.indentation;
|
|||
*
|
||||
* @author jrichard
|
||||
*/
|
||||
public class InputUseTabs {
|
||||
public class InputUseTwoSpaces {
|
||||
|
||||
/** Creates a new instance of InputUseTabs */
|
||||
public InputUseTabs() {
|
||||
public InputUseTwoSpaces() {
|
||||
boolean test = true;
|
||||
if (test)
|
||||
{
|
||||
|
|
@ -27,7 +27,7 @@ public class InputUseTabs {
|
|||
|
||||
}
|
||||
|
||||
public class Test {
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(" Hello" +
|
||||
new Object() {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class InputValidArrayInitIndent {
|
|||
{ "key", "value" }
|
||||
};
|
||||
|
||||
String[][] mStuff = new String[][]
|
||||
String[][] mStuff1 = new String[][]
|
||||
{
|
||||
{ "key", "value" }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,21 +2,21 @@ public class InputValidAssignIndent
|
|||
{
|
||||
void foo(String[] args)
|
||||
{
|
||||
i = 1 +
|
||||
int i = 1 +
|
||||
2 +
|
||||
3;
|
||||
String line = mIndentCheck[
|
||||
getLineNo()];
|
||||
String line1 =
|
||||
getLineNo();
|
||||
getLine();
|
||||
line1 =
|
||||
getLineNo();
|
||||
int i
|
||||
getLine();
|
||||
int i1
|
||||
=
|
||||
1;
|
||||
i = 3;
|
||||
|
||||
brace =
|
||||
Integer brace =
|
||||
(candidate == SLIST)
|
||||
? candidate : null;
|
||||
|
||||
|
|
@ -31,15 +31,30 @@ public class InputValidAssignIndent
|
|||
public void bar() {
|
||||
}
|
||||
};
|
||||
|
||||
function.lastArgument() = parameters;
|
||||
function.lastArgument()
|
||||
=
|
||||
parameters;
|
||||
// XXX: need to be fixed
|
||||
// function.lastArgument().candidate = parameters;
|
||||
// function.lastArgument().candidate
|
||||
// =
|
||||
// parameters;
|
||||
// TODO: add more testing
|
||||
}
|
||||
|
||||
private interface AnInterfaceFooWithALongName {
|
||||
void bar();
|
||||
}
|
||||
|
||||
private static final int SLIST = 1;
|
||||
private static final int parameters = 1;
|
||||
int candidate = 0;
|
||||
private String[] mIndentCheck = null;
|
||||
private InputValidAssignIndent function = null;
|
||||
int getLineNo() {
|
||||
return 1;
|
||||
}
|
||||
String getLine() {
|
||||
return "";
|
||||
}
|
||||
InputValidAssignIndent lastArgument() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class InputValidCommaIndent {
|
|||
}
|
||||
|
||||
public void method1(int x, int y, int z) {
|
||||
boolean test;
|
||||
boolean test = true;
|
||||
int i, j = 2,
|
||||
k = 4,
|
||||
l,
|
||||
|
|
|
|||
|
|
@ -68,18 +68,18 @@ public class InputValidDotIndent {
|
|||
Class c = javax.swing.
|
||||
plaf.metal.MetalButtonUI.class;
|
||||
|
||||
Class c = javax.swing
|
||||
Class c1 = javax.swing
|
||||
.plaf.metal.MetalButtonUI.class;
|
||||
|
||||
Class c = javax.swing
|
||||
Class c2 = javax.swing
|
||||
.plaf.metal.
|
||||
MetalButtonUI.class;
|
||||
|
||||
Class c = javax.swing
|
||||
Class c3 = javax.swing
|
||||
.plaf.metal
|
||||
.MetalButtonUI.class;
|
||||
|
||||
Class c = javax.
|
||||
Class c4 = javax.
|
||||
swing.plaf.metal.
|
||||
MetalButtonUI.class;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import java.io.ObjectStreamField;
|
||||
|
||||
public class InputConstantNames
|
||||
{
|
||||
private static final long serialVersionUID = 1L; //should be ignored
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class DescendantTokenCheckTest extends BaseCheckTestCase
|
|||
final String[] expected = {
|
||||
"12:7: Empty statement.",
|
||||
"17:7: Empty statement.",
|
||||
"22:15: Empty statement.",
|
||||
"22:19: Empty statement.",
|
||||
"26:10: Empty statement.",
|
||||
"29:16: Empty statement.",
|
||||
"33:10: Empty statement.",
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@ public class FinalParametersCheckTest extends BaseCheckTestCase
|
|||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(FinalParametersCheck.class);
|
||||
final String[] expected = {
|
||||
"22:26: Parameter s should be final.",
|
||||
"37:26: Parameter i should be final.",
|
||||
"42:26: Parameter s should be final.",
|
||||
"52:17: Parameter s should be final.",
|
||||
"68:17: Parameter s should be final.",
|
||||
"74:17: Parameter s should be final.",
|
||||
"89:38: Parameter e should be final.",
|
||||
"92:36: Parameter e should be final.",
|
||||
"109:18: Parameter aParam should be final.",
|
||||
"112:18: Parameter args should be final.",
|
||||
"115:18: Parameter args should be final.",
|
||||
"23:26: Parameter s should be final.",
|
||||
"38:26: Parameter i should be final.",
|
||||
"43:26: Parameter s should be final.",
|
||||
"53:17: Parameter s should be final.",
|
||||
"69:17: Parameter s should be final.",
|
||||
"75:17: Parameter s should be final.",
|
||||
"90:45: Parameter e should be final.",
|
||||
"93:36: Parameter e should be final.",
|
||||
"110:18: Parameter aParam should be final.",
|
||||
"113:18: Parameter args should be final.",
|
||||
"116:18: Parameter args should be final.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputFinalParameters.java"), expected);
|
||||
}
|
||||
|
|
@ -33,9 +33,9 @@ public class FinalParametersCheckTest extends BaseCheckTestCase
|
|||
createCheckConfig(FinalParametersCheck.class);
|
||||
checkConfig.addAttribute("tokens", "CTOR_DEF");
|
||||
final String[] expected = {
|
||||
"22:26: Parameter s should be final.",
|
||||
"37:26: Parameter i should be final.",
|
||||
"42:26: Parameter s should be final.",
|
||||
"23:26: Parameter s should be final.",
|
||||
"38:26: Parameter i should be final.",
|
||||
"43:26: Parameter s should be final.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputFinalParameters.java"), expected);
|
||||
}
|
||||
|
|
@ -47,14 +47,14 @@ public class FinalParametersCheckTest extends BaseCheckTestCase
|
|||
createCheckConfig(FinalParametersCheck.class);
|
||||
checkConfig.addAttribute("tokens", "METHOD_DEF");
|
||||
final String[] expected = {
|
||||
"52:17: Parameter s should be final.",
|
||||
"68:17: Parameter s should be final.",
|
||||
"74:17: Parameter s should be final.",
|
||||
"89:38: Parameter e should be final.",
|
||||
"92:36: Parameter e should be final.",
|
||||
"109:18: Parameter aParam should be final.",
|
||||
"112:18: Parameter args should be final.",
|
||||
"115:18: Parameter args should be final.",
|
||||
"53:17: Parameter s should be final.",
|
||||
"69:17: Parameter s should be final.",
|
||||
"75:17: Parameter s should be final.",
|
||||
"90:45: Parameter e should be final.",
|
||||
"93:36: Parameter e should be final.",
|
||||
"110:18: Parameter aParam should be final.",
|
||||
"113:18: Parameter args should be final.",
|
||||
"116:18: Parameter args should be final.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputFinalParameters.java"), expected);
|
||||
}
|
||||
|
|
@ -66,9 +66,9 @@ public class FinalParametersCheckTest extends BaseCheckTestCase
|
|||
createCheckConfig(FinalParametersCheck.class);
|
||||
checkConfig.addAttribute("tokens", "LITERAL_CATCH");
|
||||
final String[] expected = {
|
||||
"124:16: Parameter e should be final.",
|
||||
"127:16: Parameter npe should be final.",
|
||||
"130:16: Parameter e should be final.",
|
||||
"125:16: Parameter npe should be final.",
|
||||
"131:16: Parameter e should be final.",
|
||||
"134:16: Parameter e should be final.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputFinalParameters.java"), expected);
|
||||
}
|
||||
|
|
@ -80,8 +80,8 @@ public class FinalParametersCheckTest extends BaseCheckTestCase
|
|||
createCheckConfig(FinalParametersCheck.class);
|
||||
checkConfig.addAttribute("tokens", "FOR_EACH_CLAUSE");
|
||||
final String[] expected = {
|
||||
"149:13: Parameter s should be final.",
|
||||
"157:13: Parameter s should be final.",
|
||||
"150:13: Parameter s should be final.",
|
||||
"158:13: Parameter s should be final.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputFinalParameters.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class EmptyStatementCheckTest
|
|||
final String[] expected = {
|
||||
"12:7: Empty statement.",
|
||||
"17:7: Empty statement.",
|
||||
"22:15: Empty statement.",
|
||||
"22:19: Empty statement.",
|
||||
"26:10: Empty statement.",
|
||||
"29:16: Empty statement.",
|
||||
"33:10: Empty statement.",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class ExplicitInitializationCheckTest extends BaseCheckTestCase
|
|||
createCheckConfig(ExplicitInitializationCheck.class);
|
||||
final String[] expected = {
|
||||
"2:17: Variable 'x' explicitly initialized to '0' (default value for its type).",
|
||||
"3:17: Variable 'bar' explicitly initialized to 'null' (default value for its type).",
|
||||
"3:20: Variable 'bar' explicitly initialized to 'null' (default value for its type).",
|
||||
"7:18: Variable 'y4' explicitly initialized to '0' (default value for its type).",
|
||||
"8:21: Variable 'b1' explicitly initialized to 'false' (default value for its type).",
|
||||
"12:22: Variable 'str1' explicitly initialized to 'null' (default value for its type).",
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class HiddenFieldCheckTest
|
|||
};
|
||||
verify(checkConfig, getPath("InputHiddenField.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/** tests ignoreFormat property */
|
||||
public void testIgnoreFormat()
|
||||
throws Exception
|
||||
|
|
@ -186,7 +186,7 @@ public class HiddenFieldCheckTest
|
|||
};
|
||||
verify(checkConfig, getPath("InputHiddenField.java"), expected);
|
||||
}
|
||||
|
||||
|
||||
/** Test against a class with field declarations in different order */
|
||||
public void testReordered()
|
||||
throws Exception
|
||||
|
|
@ -211,10 +211,10 @@ public class HiddenFieldCheckTest
|
|||
"77:17: 'hidden' hides a field.",
|
||||
"83:13: 'hidden' hides a field.",
|
||||
"105:17: 'hidden' hides a field.",
|
||||
"118:20: 'hidden' hides a field.",
|
||||
"118:21: 'hidden' hides a field.",
|
||||
"125:13: 'hidden' hides a field.",
|
||||
"131:13: 'hiddenStatic' hides a field.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputHiddenFieldReorder.java"), expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public class IllegalTypeCheckTest extends BaseCheckTestCase {
|
|||
String[] expected = {
|
||||
"6:13: Declaring variables, return values or parameters of type 'AbstractClass' is not allowed.",
|
||||
"9:13: Declaring variables, return values or parameters of type "
|
||||
+ "'au.com.redhillconsulting.jamaica.tools.checkstyle.InputIllegalType.AbstractClass'"
|
||||
+ "'com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass'"
|
||||
+ " is not allowed.",
|
||||
"16:13: Declaring variables, return values or parameters of type 'java.util.Hashtable' is not allowed.",
|
||||
"17:13: Declaring variables, return values or parameters of type 'Hashtable' is not allowed.",
|
||||
|
|
@ -28,7 +28,7 @@ public class IllegalTypeCheckTest extends BaseCheckTestCase {
|
|||
String[] expected = {
|
||||
"6:13: Declaring variables, return values or parameters of type 'AbstractClass' is not allowed.",
|
||||
"9:13: Declaring variables, return values or parameters of type "
|
||||
+ "'au.com.redhillconsulting.jamaica.tools.checkstyle.InputIllegalType.AbstractClass'"
|
||||
+ "'com.puppycrawl.tools.checkstyle.checks.coding.InputIllegalType.AbstractClass'"
|
||||
+ " is not allowed.",
|
||||
"16:13: Declaring variables, return values or parameters of type 'java.util.Hashtable' is not allowed.",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ public class SuperFinalizeCheckTest
|
|||
final String[] expected = {
|
||||
"27:17: Method 'finalize' should call 'super.finalize'.",
|
||||
"34:17: Method 'finalize' should call 'super.finalize'.",
|
||||
"58:17: Method 'finalize' should call 'super.finalize'.",
|
||||
};
|
||||
verify(checkConfig, getPath("coding/InputFinalize.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class NoWhitespaceBeforeCheckTest
|
|||
"185:18: ';' is preceded with whitespace.",
|
||||
"187:27: ';' is preceded with whitespace.",
|
||||
"195:26: ';' is preceded with whitespace.",
|
||||
"208:15: ';' is preceded with whitespace.",
|
||||
"211:15: ';' is preceded with whitespace.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputWhitespace.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class ParenPadCheckTest
|
|||
"58:36: ')' is preceded with whitespace.",
|
||||
"74:13: '(' is followed by whitespace.",
|
||||
"74:18: ')' is preceded with whitespace.",
|
||||
"229:27: ')' is preceded with whitespace.",
|
||||
"232:27: ')' is preceded with whitespace.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputWhitespace.java"), expected);
|
||||
}
|
||||
|
|
@ -50,9 +50,9 @@ public class ParenPadCheckTest
|
|||
"165:10: ')' is not preceded with whitespace.",
|
||||
"178:14: '(' is not followed by whitespace.",
|
||||
"178:36: ')' is not preceded with whitespace.",
|
||||
"222:14: '(' is not followed by whitespace.",
|
||||
"232:14: '(' is not followed by whitespace.",
|
||||
"232:39: ')' is not preceded with whitespace.",
|
||||
"225:14: '(' is not followed by whitespace.",
|
||||
"235:14: '(' is not followed by whitespace.",
|
||||
"235:39: ')' is not preceded with whitespace.",
|
||||
};
|
||||
verify(checkConfig, getPath("InputWhitespace.java"), expected);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue