diff --git a/build.xml b/build.xml index 077c79c48..688a08068 100644 --- a/build.xml +++ b/build.xml @@ -180,9 +180,9 @@ - + + value="**/grammars/*,**/j2ee/*,**/InputAssertIdentifier.java,**/InputSimple.java,**/InputTags.java,**/InputJUnitTest.java,**/InputValidMethodIndent.java,**/InputSetterGetter.java,**/InputImport.java,**/InputUnusedMethod.java"/> , C extends D&E> class BadCommas < A,B,C extends Map < A,String > > { } + +// we need these interfaces for generics +interface D { +} +interface E { +} diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputHiddenField.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputHiddenField.java index 7ebf25b69..e33743647 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputHiddenField.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputHiddenField.java @@ -176,7 +176,7 @@ class StaticMethods void useX(int x) { x++; } - void useX(int y) { + void useY(int y) { y++; } } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputHiddenFieldReorder.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputHiddenFieldReorder.java index 17614d215..c1193c54d 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputHiddenFieldReorder.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputHiddenFieldReorder.java @@ -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; -} \ No newline at end of file +} diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputLeftCurlyOther.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputLeftCurlyOther.java index 273a8792d..94d8eee8e 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputLeftCurlyOther.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputLeftCurlyOther.java @@ -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 }; - } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputMagicNumber.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputMagicNumber.java index d04bf8f7c..909270b1d 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputMagicNumber.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputMagicNumber.java @@ -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); } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputMissingSwitchDefault.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputMissingSwitchDefault.java index a8fda9db3..30e8bd58d 100755 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputMissingSwitchDefault.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputMissingSwitchDefault.java @@ -1,4 +1,4 @@ -public class test { +public class InputMissingSwitchDefault { public void foo() { int i = 1; switch (i) { diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputModifier.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputModifier.java index 4c836ef06..c09903136 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputModifier.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputModifier.java @@ -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 { +} diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputNestedBlocks.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputNestedBlocks.java index 2fc6c03bd..f12cdb306 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputNestedBlocks.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputNestedBlocks.java @@ -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) diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputNewlineAtEndOfFile.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputNewlineAtEndOfFile.java index 807515fce..e2d492c99 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputNewlineAtEndOfFile.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputNewlineAtEndOfFile.java @@ -9,6 +9,6 @@ package com.puppycrawl.tools.checkstyle; * NewlineAtEndOfFileCheck. * @author Christopher Lenz **/ -public interface InputNoNewlineAtEndOfFile +public interface InputNewlineAtEndOfFile { } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputSimple.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputSimple.java index 0c6e3a022..9c29e4ce1 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputSimple.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputSimple.java @@ -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; -} \ No newline at end of file +} diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputTags.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputTags.java index 8a3e8ecf6..1daa14daf 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputTags.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputTags.java @@ -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() { } /** diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputUncommentedMain.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputUncommentedMain.java index 54f02f7de..9fbf8359d 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputUncommentedMain.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputUncommentedMain.java @@ -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() diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/InputWhitespace.java b/src/testinputs/com/puppycrawl/tools/checkstyle/InputWhitespace.java index b294d174d..ed26b2e6d 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/InputWhitespace.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/InputWhitespace.java @@ -196,6 +196,9 @@ class InputWhitespace // ^ whitespace }; } + + void doStuff() { + } } /** @@ -233,4 +236,8 @@ class SpecialCasesInForLoop //Should be ignored } } -} \ No newline at end of file + + int[] getSomeInts() { + return null; + } +} diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputDeclarationOrder.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputDeclarationOrder.java index c10901a5b..213addcd1 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputDeclarationOrder.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputDeclarationOrder.java @@ -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; -} \ No newline at end of file +} diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputExplicitInit.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputExplicitInit.java index 9c5738c63..573773537 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputExplicitInit.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputExplicitInit.java @@ -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; } } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFallThrough.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFallThrough.java index 89f7c203a..17a7137e6 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFallThrough.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFallThrough.java @@ -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!!! diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFinalLocalVariable.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFinalLocalVariable.java index abba0ad56..22be5656c 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFinalLocalVariable.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFinalLocalVariable.java @@ -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; + } } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFinalize.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFinalize.java index b58327526..b23e385e4 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFinalize.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputFinalize.java @@ -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() - } -} \ No newline at end of file diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputIllegalType.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputIllegalType.java index b9dba3efa..6d5b6c73b 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputIllegalType.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputIllegalType.java @@ -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 {} diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputModifiedControl.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputModifiedControl.java index 4960bc7c7..2f763a823 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputModifiedControl.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputModifiedControl.java @@ -3,7 +3,7 @@ // Created: 2003 //////////////////////////////////////////////////////////////////////////////// package com.puppycrawl.tools.checkstyle; - +import java.io.Serializable; class InputModifiedControl { int k; diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputMultipleVariableDeclarations.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputMultipleVariableDeclarations.java index 3018c8b02..9af7b25df 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputMultipleVariableDeclarations.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputMultipleVariableDeclarations.java @@ -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--) { diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputParameterAssignment.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputParameterAssignment.java index 9c6837d9b..3a55c0126 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputParameterAssignment.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputParameterAssignment.java @@ -17,6 +17,6 @@ public class InputParameterAssignment { } void foo3(String field, int field1) { - this.field = (field1 += field.length); + this.field = (field1 += field.length()); } } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputRequireThis.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputRequireThis.java index 526dcbcf2..128f36718 100755 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputRequireThis.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputRequireThis.java @@ -10,7 +10,6 @@ public class InputRequireThis { i++; this.i = i; method1(); - j--; // unhandled for now try { this.method1(); } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputReturnFromCatchCheck.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputReturnFromCatchCheck.java index c74f77fbd..d0519a067 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputReturnFromCatchCheck.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputReturnFromCatchCheck.java @@ -1,6 +1,6 @@ package com.puppycrawl.tools.checkstyle.coding; -public class ReturnFromCatchCheckTestInput { +public class InputReturnFromCatchCheck { public void foo() { try { System.currentTimeMillis(); diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputReturnFromFinallyCheck.java b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputReturnFromFinallyCheck.java index 548412383..8fcea235a 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputReturnFromFinallyCheck.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/coding/InputReturnFromFinallyCheck.java @@ -1,6 +1,6 @@ package com.puppycrawl.tools.checkstyle.coding; -public class ReturnFromFinallyCheckTestInput { +public class InputReturnFromFinallyCheck { public void foo() { try { System.currentTimeMillis(); diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputInvalidAssignIndent.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputInvalidAssignIndent.java index 354482021..df896d021 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputInvalidAssignIndent.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputInvalidAssignIndent.java @@ -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 ""; + } } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputInvalidMethodIndent.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputInvalidMethodIndent.java index 213300fe9..fb3a96dc8 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputInvalidMethodIndent.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputInvalidMethodIndent.java @@ -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") ); diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputUseTwoSpaces.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputUseTwoSpaces.java index fb8192f9d..99838961b 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputUseTwoSpaces.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputUseTwoSpaces.java @@ -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() { diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidArrayInitIndent.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidArrayInitIndent.java index 9d7e5013e..54833c4ba 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidArrayInitIndent.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidArrayInitIndent.java @@ -58,7 +58,7 @@ public class InputValidArrayInitIndent { { "key", "value" } }; - String[][] mStuff = new String[][] + String[][] mStuff1 = new String[][] { { "key", "value" } }; diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidAssignIndent.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidAssignIndent.java index 1676e30c1..86ae87151 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidAssignIndent.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidAssignIndent.java @@ -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; + } } diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidCommaIndent.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidCommaIndent.java index 9c5fe6272..3c80a9cd4 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidCommaIndent.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidCommaIndent.java @@ -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, diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidDotIndent.java b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidDotIndent.java index 02a1f6c8f..473b4516f 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidDotIndent.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/indentation/InputValidDotIndent.java @@ -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; diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/naming/InputConstantNames.java b/src/testinputs/com/puppycrawl/tools/checkstyle/naming/InputConstantNames.java index ba0f51ce9..3abe369b8 100644 --- a/src/testinputs/com/puppycrawl/tools/checkstyle/naming/InputConstantNames.java +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/naming/InputConstantNames.java @@ -1,3 +1,5 @@ +import java.io.ObjectStreamField; + public class InputConstantNames { private static final long serialVersionUID = 1L; //should be ignored diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java index cd6ac249b..20ee2f487 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java @@ -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.", diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java index 40255cad7..70907c705 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java @@ -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); } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java index 5b5493dce..f83c298e6 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java @@ -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.", diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java index 5fa179a53..ec1521da5 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java @@ -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).", diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java index 2a87fffe1..4e72a927f 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java @@ -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); } -} \ No newline at end of file +} diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java index f68e450fa..e2dec9b72 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java @@ -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.", }; diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java index b4a343219..bcf70045a 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java @@ -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); } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java index 131ad349b..70d2a4ea0 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java @@ -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); } diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java index a0f10be48..c096c224a 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java @@ -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); }