diff options
Diffstat (limited to 'src/test/resources/com')
69 files changed, 700 insertions, 65 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough.java index a3c745e55..384499fb3 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/fallthrough/InputFallThrough.java @@ -547,4 +547,17 @@ public class InputFallThrough break; } } + + void multipleCasesOnOneLine() { + int i = 0; + switch (i) { + case 0: case 1: i *= i; // fall through + case 2: case 3: i *= i; // fall through + case 4: case 5: i *= i; // fall through + case 6: case 7: i *= i; + break; + default: + throw new RuntimeException(); + } + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalType.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalType.java index dfce5fddc..2efc892ca 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalType.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/illegaltype/InputIllegalType.java @@ -21,4 +21,6 @@ public class InputIllegalType { InputIllegalType(Integer i) {} private void table2(Integer i) {} + + private void getInitialContext(java.util.TreeSet v) {} // ignore method by default } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/modifiedcontrolvariable/InputModifiedControlVariableBothForLoops.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/modifiedcontrolvariable/InputModifiedControlVariableBothForLoops.java index d3f57c7be..01c24149c 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/modifiedcontrolvariable/InputModifiedControlVariableBothForLoops.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/modifiedcontrolvariable/InputModifiedControlVariableBothForLoops.java @@ -70,6 +70,13 @@ class InputModifiedControlVariableBothForLoops for (int i = 0,j = 0 ; i <10; i++) { j++; } + + for (String v : sa) { + new NestedClass() { + public void method() {} + }; + v = "bad"; + } } private int i; } @@ -83,3 +90,6 @@ class VariableDeclaredBeforeTheFirstBlockBegins { } } } +abstract class NestedClass { + public abstract void method(); +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/multiplevariabledeclarations/InputMultipleVariableDeclarations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/multiplevariabledeclarations/InputMultipleVariableDeclarations.java index 16487fb9c..d178fbfa0 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/multiplevariabledeclarations/InputMultipleVariableDeclarations.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/multiplevariabledeclarations/InputMultipleVariableDeclarations.java @@ -30,4 +30,8 @@ public class InputMultipleVariableDeclarations int k = 7; } } + + void method3() { + java.lang.Object obj; Object obj1; Object obj2; Object obj3; + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/nestedfordepth/InputNestedForDepth.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/nestedfordepth/InputNestedForDepth.java index dfa0eb6c2..cfa8356e7 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/nestedfordepth/InputNestedForDepth.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/nestedfordepth/InputNestedForDepth.java @@ -44,6 +44,9 @@ public class InputNestedForDepth { for (i5 = 0; i5 < 10; i5++) { i += 1; } + for (int i5a = 0; i5a < 10; i5a++) { + i += 1; + } } } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/onestatementperline/InputOneStatementPerLineSingleLine.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/onestatementperline/InputOneStatementPerLineSingleLine.java index 185b7b74f..4a20cb731 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/onestatementperline/InputOneStatementPerLineSingleLine.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/onestatementperline/InputOneStatementPerLineSingleLine.java @@ -238,4 +238,11 @@ public class InputOneStatementPerLineSingleLine { */ for (;;) { one = 5; } } + + public void foo6() { + bar(() -> { + return;}, () -> {return;}); + } + + void bar(Runnable r1, Runnable r2) { } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/parameterassignment/InputParameterAssignmentWithUnchecked.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/parameterassignment/InputParameterAssignmentWithUnchecked.java index 60f8eed0b..fbfc6e786 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/parameterassignment/InputParameterAssignmentWithUnchecked.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/parameterassignment/InputParameterAssignmentWithUnchecked.java @@ -19,4 +19,17 @@ public class InputParameterAssignmentWithUnchecked { void foo3(String field, int field1) { this.field = (field1 += field.length()); } + + void foo4() { + String hidden = ""; + new NestedClass() { + public void test(String hidden) { + } + }; + hidden += "test"; + } + + public static abstract class NestedClass { + public abstract void test(String hidden); + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisAnnotationInterface.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisAnnotationInterface.java new file mode 100644 index 000000000..b7b35495c --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisAnnotationInterface.java @@ -0,0 +1,9 @@ +package com.puppycrawl.tools.checkstyle.checks.coding.requirethis; + +public @interface InputRequireThisAnnotationInterface { + String DEFAULT_VALUE = "DEFAULT_VALUE"; + + String value() default DEFAULT_VALUE; + + String[] results() default {}; +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisCatchVariables.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisCatchVariables.java new file mode 100644 index 000000000..920dd6369 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisCatchVariables.java @@ -0,0 +1,40 @@ +package com.puppycrawl.tools.checkstyle.checks.coding.requirethis; + +public class InputRequireThisCatchVariables extends Thread { + private Throwable ex; + + public InputRequireThisCatchVariables(Throwable ex) { + this.ex = ex; + } + + @Override + public void run() { + if (this.ex != null) { + try { + exceptional(this.ex); + } + catch (RuntimeException ex) { + if (ex == this.ex) { + debug("Expected exception thrown", ex); + } + else { + ex.printStackTrace(); + } + } + catch (Error err) { + if (err == this.ex) { + debug("Expected exception thrown", err); + } + else { + ex.printStackTrace(); + } + } + catch (Throwable ex) { + ex.printStackTrace(); + } + } + } + + private static void exceptional(Throwable ex) {} + private static void debug(String message, Throwable err) {} +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisEnumConstant.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisEnumConstant.java new file mode 100644 index 000000000..4cfc3b3de --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisEnumConstant.java @@ -0,0 +1,13 @@ +package com.puppycrawl.tools.checkstyle.checks.coding.requirethis; + +public class InputRequireThisEnumConstant { + private final String TEST = ""; + + public enum TestEnum { + TEST; + + public TestEnum method() { + return TEST; + } + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisEnumInnerClassesAndBugs.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisEnumInnerClassesAndBugs.java index a0bd74681..77beca3a7 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisEnumInnerClassesAndBugs.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisEnumInnerClassesAndBugs.java @@ -134,3 +134,43 @@ class Issue2539{ foo(); } } +class NestedRechange { + final String s = ""; + + NestedRechange() { + String s = "t"; + s = s.substring(0); + } + + private static class NestedStatic { + static final String s = ""; + + public void method() { + s.substring(0); + } + } +} +class NestedFrames { + int a = 0; + int b = 0; + + public int oneReturnInMethod2() { + for (int i = 0; i < 10; i++) { + int a = 1; + if (a != 2 && true) { + if (true | false) { + if (a - a != 0) { + a += 1; + } + } + } + } + return a + a * a; + } + + public int oneReturnInMethod3() { + for (int b = 0; b < 10; b++) { + } + return b + b * b; + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisFor.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisFor.java new file mode 100644 index 000000000..9ad0e9f5c --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisFor.java @@ -0,0 +1,23 @@ +package com.puppycrawl.tools.checkstyle.checks.coding.requirethis; + +import java.nio.file.Path; +import java.nio.file.Paths; + +public class InputRequireThisFor { + private String name; + int bottom; + + public void method1() { + for (int i = 0; i < 10; i++) { + int bottom = i - 4; + bottom = bottom > 0 ? bottom - 1 : bottom; + } + } + + public void method2() { + for (String name : new String[]{}) { + } + + Path jarfile = Paths.get(name + ".jar"); + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisMetodReferences.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisMethodReferences.java index 516b85aed..b0b528e81 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisMetodReferences.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/requirethis/InputRequireThisMethodReferences.java @@ -6,16 +6,16 @@ import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; -public class InputRequireThisMetodReferences { +public class InputRequireThisMethodReferences { private Set<String> tags = Collections.unmodifiableSortedSet( Arrays.stream(new String[] {"br", "li", "dt", "dd", "hr", "img", "p", "td", "tr", "th",}) .collect(Collectors.toCollection(TreeSet::new))); - public InputRequireThisMetodReferences(Set<String> tags) { + public InputRequireThisMethodReferences(Set<String> tags) { tags = tags; // violation } - public InputRequireThisMetodReferences() { + public InputRequireThisMethodReferences() { this.tags = Arrays.stream( new String[] {"br", "li", "dt", "dd", "hr", "img", "p", "td", "tr", "th",}) .collect(Collectors.toCollection(TreeSet::new)); diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/returncount/InputReturnCountVoid.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/returncount/InputReturnCountVoid.java index 9a2d48faa..a1beceeae 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/returncount/InputReturnCountVoid.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/returncount/InputReturnCountVoid.java @@ -37,4 +37,12 @@ class InputReturnCountVoid { return 0; } + + void method5() { + if (true) { + return; + } + + return; + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessaryparentheses/InputUnnecessaryParenthesesOperatorsAndCasts.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessaryparentheses/InputUnnecessaryParenthesesOperatorsAndCasts.java index 777f4b15e..33246c199 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessaryparentheses/InputUnnecessaryParenthesesOperatorsAndCasts.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/unnecessaryparentheses/InputUnnecessaryParenthesesOperatorsAndCasts.java @@ -87,6 +87,14 @@ public class InputUnnecessaryParenthesesOperatorsAndCasts { System.identityHashCode("arg = " + arg); } + private int f7() { + String f; + + f = ("12345678901234567890123"); + + return 0; + } + static class TypeParameterized<T> {} static class TypeA extends TypeParameterized<String> {} static class TypeB extends TypeA {} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistance.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistance.java index 57ca5e725..330abb819 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistance.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistance.java @@ -973,5 +973,16 @@ class New { } catch(Exception e){} } + + void m() { + final int a = 1; + int b = 0; + + if (b == 1) { + System.lineSeparator(); + } + + final int c = a + 1; + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistanceAnonymous.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistanceAnonymous.java new file mode 100644 index 000000000..969aa801f --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistanceAnonymous.java @@ -0,0 +1,22 @@ +package com.puppycrawl.tools.checkstyle.checks.coding.variabledeclarationusagedistance; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JMenuItem; + +public class InputVariableDeclarationUsageDistanceAnonymous { + public void method() { + JMenuItem prefs = new JMenuItem("Preferences..."); + + nothing(); + nothing(); + nothing(); + prefs.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + } + }); + } + + public void nothing() { + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistanceLabels.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistanceLabels.java new file mode 100644 index 000000000..e9e0e3ff4 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/variabledeclarationusagedistance/InputVariableDeclarationUsageDistanceLabels.java @@ -0,0 +1,22 @@ +package com.puppycrawl.tools.checkstyle.checks.coding.variabledeclarationusagedistance; + +public class InputVariableDeclarationUsageDistanceLabels { + public void method() { + boolean eol = false; + + nothing(); + nothing(); + nothing(); + nothing(); + myLoop: + for (int i = 0; i < 5; i++) { + if (i == 5) { + eol = true; + break myLoop; + } + } + } + + public void nothing() { + } +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/throwscount/InputThrowsCountMwthodWithAnnotation.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/throwscount/InputThrowsCountMethodWithAnnotation.java index 879343553..20a61431f 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/throwscount/InputThrowsCountMwthodWithAnnotation.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/throwscount/InputThrowsCountMethodWithAnnotation.java @@ -6,7 +6,7 @@ import java.io.FileNotFoundException; import java.nio.file.FileAlreadyExistsException; import java.sql.SQLException; -public class InputThrowsCountMwthodWithAnnotation extends ParentClass { +public class InputThrowsCountMethodWithAnnotation extends ParentClass { @Override public void method() throws AWTException, SQLException, FileNotFoundException, EOFException, FileAlreadyExistsException { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/customimportorder/InputCustomImportOrderCompareImports.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/customimportorder/InputCustomImportOrderCompareImports.java new file mode 100644 index 000000000..a32b01951 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/customimportorder/InputCustomImportOrderCompareImports.java @@ -0,0 +1,10 @@ +package com.puppycrawl.tools.checkstyle.checks.imports.customimportorder; + +import java.util.Map.Entry; +import java.util.Map; + +import com.google.common.*; +import com.google.common.annotations.*; + +public class InputCustomImportOrderCompareImports { +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/customimportorder/InputCustomImportOrderFindBetterPatternMatch.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/customimportorder/InputCustomImportOrderFindBetterPatternMatch.java new file mode 100644 index 000000000..0e316b9bc --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/customimportorder/InputCustomImportOrderFindBetterPatternMatch.java @@ -0,0 +1,13 @@ +package com.puppycrawl.tools.checkstyle.checks.imports.customimportorder; + +import javax.lang.model.element.AnnotationValue; +import java.awt.event.ActionEvent; +import java.lang.*; +import java.awt.color.ColorSpace; + +import com.google.common.annotations.Beta; + +import com.google.common.collect.HashMultimap; + +public class InputCustomImportOrderFindBetterPatternMatch { +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderRepetiton.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderRepetition.java index 78456928e..9597953b2 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderRepetiton.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderRepetition.java @@ -8,5 +8,5 @@ import java.awt.event.ActionEvent; //Repetitive import import javax.swing.JComponent; import javax.swing.JTable; -public class InputImportOrderRepetiton { +public class InputImportOrderRepetition { } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupOrderBottom_Negative.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupOrderBottom_Negative.java new file mode 100644 index 000000000..e093b04da --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupOrderBottom_Negative.java @@ -0,0 +1,13 @@ +package com.puppycrawl.tools.checkstyle.checks.imports.importorder; + +import org.*; + +import static java.lang.Math.PI; +import static org.antlr.v4.runtime.Recognizer.EOF; + +import java.util.Set; + +public class InputImportOrderStaticGroupOrderBottom_Negative +{ + +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupOrderBottom_Negative2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupOrderBottom_Negative2.java new file mode 100644 index 000000000..61277ad75 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupOrderBottom_Negative2.java @@ -0,0 +1,15 @@ +package com.puppycrawl.tools.checkstyle.checks.imports.importorder; + +import org.*; + +import static java.lang.Math.PI; +import static org.antlr.v4.runtime.Recognizer.EOF; + +import java.util.Set; + +import static java.util.Set.*; + +public class InputImportOrderStaticGroupOrderBottom_Negative2 +{ + +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupSeperated.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupSeparated.java index dd06f8df5..2528dc279 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupSeperated.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/imports/importorder/InputImportOrderStaticGroupSeparated.java @@ -7,7 +7,7 @@ import static java.lang.Math.cos;; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -public class InputImportOrderStaticGroupSeperated { +public class InputImportOrderStaticGroupSeparated { void method() { } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationAnnotationIncorrect.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationAnnotationIncorrect.java new file mode 100644 index 000000000..20d878423 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationAnnotationIncorrect.java @@ -0,0 +1,24 @@ +package com.puppycrawl.tools.checkstyle.checks.indentation.indentation; //indent:0 exp:0 + +class InpuIndentationAnnotationIncorrect { //indent:0 exp:0 + + public @interface MyAnnotation1 { //indent:4 exp:4 + String value(); //indent:8 exp:8 + } //indent:4 exp:4 + + @MyAnnotation2 //indent:4 exp:4 + @MyAnnotation1 //indent:4 exp:4 + (value = "") //indent:4 exp:8 + class innerClass { //indent:4 exp:4 + @MyAnnotation2 @MyAnnotation1 //indent:8 exp:8 + (value = "") //indent:8 exp:12 + public int a; //indent:8 exp:8 + } //indent:4 exp:4 + + @MyAnnotation2 @MyAnnotation1 //indent:4 exp:4 + (value = "") //indent:4 exp:8 + class InputIndentationAnnotationInnerClass { //indent:4 exp:4 + + } //indent:4 exp:4 +} //indent:0 exp:0 + diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationMethodPrecededByAnnotationWithParameterOnSeparateLine.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationMethodPrecededByAnnotationWithParameterOnSeparateLine.java new file mode 100644 index 000000000..b0ea5d2de --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/indentation/InputIndentationMethodPrecededByAnnotationWithParameterOnSeparateLine.java @@ -0,0 +1,20 @@ +package com.puppycrawl.tools.checkstyle.checks.indentation.indentation; //indent:0 exp:0 + +public class InputIndentationMethodPrecededByAnnotationWithParameterOnSeparateLine { //indent:0 exp:0 + + @interface Annotation1 { //indent:2 exp:2 + String field1(); //indent:4 exp:4 + String field2(); //indent:4 exp:4 + } //indent:2 exp:2 + + @interface Annotation2 {}; //indent:2 exp:2 + + @Annotation1(field1 = "foo", field2 = "bar") //indent:2 exp:2 + public @Annotation2 String method( //indent:2 exp:2 + String param //indent:6 exp:6 + ) { //indent:2 exp:2 + return null; //indent:4 exp:4 + } //indent:2 exp:2 + +} //indent:0 exp:0 + diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc/InputAbstractJavadocPosition.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc/InputAbstractJavadocPosition.java index c83a6078e..258c51185 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc/InputAbstractJavadocPosition.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc/InputAbstractJavadocPosition.java @@ -95,6 +95,11 @@ class GGG { void/**nope*/ a/**nope*/(@Component/**nope*/int/**nope*/ a/**nope*/)/**nope*/{/**nope*/}/**nope*/ } +class HHH { + /**Javadoc*/ + java.lang.String/**nope*/ a/**nope*/()/**nope*/{/**nope*/return null;/**nope*/}/**nope*/ +} + //////////////// // INTERFACES // //////////////// @@ -229,7 +234,14 @@ enum CCCCCCC { } /**Javadoc*/ -@interface/**nope*/ MyAnnotation/**nope*/ {/**nope*/ +@interface/**nope*/ MyAnnotation/**nope*/ { + /**Javadoc*/ + @Component/**nope*/abstract/**nope*/String/**nope*/val1()/**nope*/default/**nope*/""; + /**Javadoc*/ + abstract/**nope*/String/**nope*/val2()/**nope*/; + /**Javadoc*/ + java.lang.String/**nope*/val3()/**nope*/; + /**nope*/ } class MyTemp1 { @@ -239,3 +251,28 @@ class MyTemp1 { } /**nope*/ +/*noise*/ +/**nope*/ +/**Javadoc*/ +//noise +@Component +/*noise*/ +interface MultipleJavadoc { + /**nope*/ + /*noise*/ + /**nope*/ + /**Javadoc*/ + /* noise */ + public /**nope*/ int method(); + /**nope*/ + /*noise*/ + /**nope*/ + /**Javadoc*/ + // noise + @Deprecated + // noise + /**nope*/ + public /**nope*/ void method2(); +} + +/**nope*/ diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc/InputAbstractJavadocPositionWithSinglelineComments.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc/InputAbstractJavadocPositionWithSinglelineComments.java index c95e4708b..3f320c17e 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc/InputAbstractJavadocPositionWithSinglelineComments.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/abstractjavadoc/InputAbstractJavadocPositionWithSinglelineComments.java @@ -95,6 +95,11 @@ class LKJ { void/**nope*/ a/**nope*/(@Component2/**nope*/int/**nope*/ a/**nope*/)/**nope*/{/**nope*/}/**nope*/ } +class LKM { + /**Javadoc*/ //noise + java.lang.String/**nope*/ a/**nope*/(/**nope*/)/**nope*/{/**nope*/return null;/**nope*/}/**nope*/ +} + //////////////// // INTERFACES // //////////////// @@ -230,7 +235,14 @@ enum XXXXXXX { } /**Javadoc*/ //noise -@interface/**nope*/ MyAnnotation2/**nope*/ {/**nope*/ +@interface/**nope*/ MyAnnotation2/**nope*/ { + /**Javadoc*/ //noise + @Component2/**nope*/abstract/**nope*/String/**nope*/val1()/**nope*/default/**nope*/""; + /**Javadoc*/ //noise + abstract/**nope*/String/**nope*/val2()/**nope*/; + /**Javadoc*/ //noise + java.lang.String/**nope*/val3()/**nope*/; + /**nope*/ } class MyTemp2 { @@ -239,4 +251,16 @@ class MyTemp2 { } } +/**nope*/ /*noise*/ /**nope*/ /**Javadoc*/ //noise +interface MultipleJavadocs2 { + /**nope*/ /*noise*/ /**nope*/ /**Javadoc*/ //noise + int method(); + /**nope*/ /*noise*/ /**nope*/ /**Javadoc*/ //noise + @Deprecated + /**nope*/ /*noise*/ /**nope*/ //noise + public + /**nope*/ /*noise*/ /**nope*/ //noise + void method2(); +} + /**nope*/ diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadocmethod/InputJavadocMethodTags.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadocmethod/InputJavadocMethodTags.java index 1926f2de4..0766afea3 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadocmethod/InputJavadocMethodTags.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/javadocmethod/InputJavadocMethodTags.java @@ -297,6 +297,14 @@ class InputJavadocMethodTags1 return 1; } + + /** + * misplaced @param aParam + * misplaced @return something very important. + */ + int method29(int aParam) + { return 0; + } } enum InputJavadocMethodTagsEnum diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescription.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescription.java index bf3346d00..1251e9955 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescription.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/javadoc/nonemptyatclausedescription/InputNonEmptyAtclauseDescription.java @@ -96,4 +96,31 @@ class InputNonEmptyAtclauseDescription { return 1; } + + /** + * Some javadoc + * @param a Some javadoc + * @param b Some javadoc + * @param c Some javadoc + * @return Some javadoc + * @exception Exception Some javadoc + * @deprecated Some javadoc + */ + public int foo5(String a, int b, double c) throws Exception + { + return 1; + } + + /** + * + * @param a Some javadoc + * @param b Some javadoc + * @param c Some javadoc + * @return Some javadoc + * @exception Exception + */ + public int foo6(String a, int b, double c) throws Exception + { + return 1; + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity/InputBooleanExpressionComplexity.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity/InputBooleanExpressionComplexity.java index 8d5bd7a13..1c8b48131 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity/InputBooleanExpressionComplexity.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity/InputBooleanExpressionComplexity.java @@ -24,6 +24,13 @@ public class InputBooleanExpressionComplexity { } public boolean equals(Object object) { + new NestedClass() { + public void method() { + new Settings(Settings.FALSE || Settings.FALSE || Settings.FALSE || Settings.FALSE || Settings.FALSE); + } + public void method2() { + } + }; return (((_a && (_b & _c)) || (_c ^ _d) || (_a && _d))); } @@ -68,4 +75,9 @@ public class InputBooleanExpressionComplexity { { } } + + abstract class NestedClass { + public abstract void method(); + public abstract void method2(); + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/classfanoutcomplexity/InputClassFanOutComplexityPackageName.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/classfanoutcomplexity/InputClassFanOutComplexityPackageName.java new file mode 100644 index 000000000..c0386f196 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/classfanoutcomplexity/InputClassFanOutComplexityPackageName.java @@ -0,0 +1,7 @@ +package com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity; + +public interface InputClassFanOutComplexityPackageName { + public com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity.InputClassFanOutComplexityPackageName method1(); + + public com.puppycrawl.tools.checkstyle.checks.metrics.classfanoutcomplexity.InputClassFanOutComplexityPackageName method2(); +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/npathcomplexity/InputNPathComplexityDefault.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/npathcomplexity/InputNPathComplexityDefault.java index 390d4dd44..fe4a52a08 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/npathcomplexity/InputNPathComplexityDefault.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/metrics/npathcomplexity/InputNPathComplexityDefault.java @@ -109,4 +109,17 @@ public class InputNPathComplexityDefault { }; new Thread(runnable).start(); } + + public void InputNestedTernaryCheck() { + double x = (getSmth() || Math.random() == 5) ? null : (int) Math + .cos(400 * (10 + 40)); // good + double y = (0.2 == Math.random()) ? (0.3 == Math.random()) ? null : (int) Math + .cos(400 * (10 + 40)) : 6; // bad (nested in first position) + double z = (Integer) ((0.2 == Math.random()) ? (Integer) null + apply(null) + : (0.3 == Math.random()) ? (Integer) null : (int) Math + .sin(300 * (12 + 30))); // bad (nested in second + // position) + } + public boolean getSmth() { return true; }; + public int apply(Object o) { return 0; } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierFinalInEnumStaticMethods.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierFinalInEnumStaticMethods.java new file mode 100644 index 000000000..0668729c0 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierFinalInEnumStaticMethods.java @@ -0,0 +1,16 @@ +package com.puppycrawl.tools.checkstyle.checks.modifier.redundantmodifier; + +public class InputRedundantModifierFinalInEnumStaticMethods { + public enum TestEnum { + VALUE { + @Override public void someMethodToOverride() { + // do it differently + } + }; + + public void someMethodToOverride() { } + public static final void someStaticMethod() { } //violation + public static void someMethod() { } + } +} + diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/InputMethodNameEqualClassName.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/InputMethodNameEqualClassName.java index 277ab486f..5a9ed016e 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/InputMethodNameEqualClassName.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/InputMethodNameEqualClassName.java @@ -47,10 +47,10 @@ interface SweetInterface { int SweetInterface(); } -class Outter { +class Outer { //illegal name - public void Outter() { + public void Outer() { } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/InputMethodNameOverridenMethods.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/InputMethodNameOverriddenMethods.java index c253ffaf9..102be8bbe 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/InputMethodNameOverridenMethods.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/naming/methodname/InputMethodNameOverriddenMethods.java @@ -1,6 +1,6 @@ package com.puppycrawl.tools.checkstyle.checks.naming.methodname; -public class InputMethodNameOverridenMethods extends SomeClass +public class InputMethodNameOverriddenMethods extends SomeClass { @Override public void PUBLICfoo() { //Ignored due to impossibility of change by developer diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/ExpectedTranslationLog.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/ExpectedTranslationLog.xml new file mode 100644 index 000000000..7f7a77215 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/ExpectedTranslationLog.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version="8.3-SNAPSHOT"> +<file name="InputTranslationCheckFireErrors.properties"> +</file> +<file name="InputTranslationCheckFireErrors_de.properties"> +</file> +<file name=""> +<error line="0" severity="error" message="$0" source="com.puppycrawl.tools.checkstyle.checks.TranslationCheck"/> +</file> +<file name="InputTranslationCheckFireErrors.properties"> +</file> +<file name="InputTranslationCheckFireErrors_de.properties"> +<error line="0" severity="error" message="$1" source="com.puppycrawl.tools.checkstyle.checks.TranslationCheck"/> +</file> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckLinux.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckLinux.xml deleted file mode 100644 index 34a16cbbe..000000000 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckLinux.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<checkstyle version="8.3-SNAPSHOT"> -<file name="path_to_file/InputTranslationCheckFireErrors.properties"> -</file> -<file name="path_to_file/InputTranslationCheckFireErrors_de.properties"> -</file> -<file name="path_to_file"> -<error line="0" severity="error" message="%s" source="com.puppycrawl.tools.checkstyle.checks.TranslationCheck"/> -</file> -<file name="path_to_file/InputTranslationCheckFireErrors.properties"> -</file> -<file name="path_to_file/InputTranslationCheckFireErrors_de.properties"> -<error line="0" severity="error" message="%s" source="com.puppycrawl.tools.checkstyle.checks.TranslationCheck"/> -</file> -</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckMacOS.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckMacOS.xml deleted file mode 100644 index 865791fde..000000000 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckMacOS.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<checkstyle version="8.3-SNAPSHOT"> -<file name="path_to_file/InputTranslationCheckFireErrors.properties"> -</file> -<file name="path_to_file/InputTranslationCheckFireErrors_de.properties"> -</file> -<file name="path_to_file"> -<error line="0" severity="error" message="%s" source="com.puppycrawl.tools.checkstyle.checks.TranslationCheck"/> -</file> -<file name="path_to_file/InputTranslationCheckFireErrors_de.properties"> -<error line="0" severity="error" message="%s" source="com.puppycrawl.tools.checkstyle.checks.TranslationCheck"/> -</file> -<file name="path_to_file/InputTranslationCheckFireErrors.properties"> -</file> -</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckWindows.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckWindows.xml deleted file mode 100644 index 443bba39b..000000000 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/translation/OutputTranslationCheckWindows.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<checkstyle version="8.3-SNAPSHOT"> -<file name="path_to_file\InputTranslationCheckFireErrors.properties"> -</file> -<file name="path_to_file\InputTranslationCheckFireErrors_de.properties"> -</file> -<file name="path_to_file"> -<error line="0" severity="error" message="%s" source="com.puppycrawl.tools.checkstyle.checks.TranslationCheck"/> -</file> -<file name="path_to_file\InputTranslationCheckFireErrors.properties"> -</file> -<file name="path_to_file\InputTranslationCheckFireErrors_de.properties"> -<error line="0" severity="error" message="%s" source="com.puppycrawl.tools.checkstyle.checks.TranslationCheck"/> -</file> -</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfter.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfter.java index 4cdd50621..34f62a329 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfter.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfter.java @@ -291,4 +291,8 @@ class SpecialCasesInForLoop @ interface BAD3{} @interface Ok{} + + static { + int[]err = new int [50]; + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterArrayDeclarations.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterArrayDeclarations.java index 9ba53befb..001bd78e3 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterArrayDeclarations.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterArrayDeclarations.java @@ -37,10 +37,10 @@ public class InputNoWhitespaceAfterArrayDeclarations }; } int ar [] = new int [] {1, 2}; //Incorrect (2 warnings) - private int [][][] getMultArray() { //Incorrect + private int [][][] getMultiArray() { //Incorrect return null; } - private long getLongMultArray(int someParam, String value) [][][] { //Incorrect + private long getLongMultiArray(int someParam, String value) [][][] { //Incorrect return null; } int aa = new int[]{1}[0];//Correct diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterArrayDeclarations2.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterArrayDeclarations2.java index f632316f8..7a33245b2 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterArrayDeclarations2.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter/InputNoWhitespaceAfterArrayDeclarations2.java @@ -103,6 +103,14 @@ public class InputNoWhitespaceAfterArrayDeclarations2 if(someStuff15 instanceof Object[][]) { } + Object[] a = null; + + if(a instanceof Object []) {//incorrect + + } + if(a instanceof Object[][]) { + + } } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/configurationloader/InputConfigurationLoaderNonexistingProperty.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/configurationloader/InputConfigurationLoaderNonexistentProperty.xml index 95bb8a3f1..58441ac91 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/configurationloader/InputConfigurationLoaderNonexistingProperty.xml +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/configurationloader/InputConfigurationLoaderNonexistentProperty.xml @@ -5,5 +5,5 @@ "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd"> <module name="Checker"> - <property name="tabWidth" value="${nonexisting}" /> + <property name="tabWidth" value="${nonexistent}" /> </module> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsloader/InputSuppressionsLoaderMultiple.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsloader/InputSuppressionsLoaderMultiple.xml index 283d5505a..3754f2d27 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsloader/InputSuppressionsLoaderMultiple.xml +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsloader/InputSuppressionsLoaderMultiple.xml @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suppressions PUBLIC - "-//Puppy Crawl//DTD Suppressions 1.0//EN" - "http://checkstyle.sourceforge.net/dtds/suppressions_1_0.dtd"> + "-//Puppy Crawl//DTD Suppressions 1.2//EN" + "http://checkstyle.sourceforge.net/dtds/suppressions_1_2.dtd"> <suppressions> <suppress files="file0" checks="check0"/> <suppress files="file1" checks="check1" lines="1,2-3"/> <suppress files="file2" checks="check2" columns="1,2-3"/> <suppress files="file3" checks="check3" lines="1,2-3" columns="1,2-3"/> + <suppress message="message0"/> </suppressions> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsloader/InputSuppressionsLoaderXpathCorrect.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsloader/InputSuppressionsLoaderXpathCorrect.xml index d1e284a4e..05aa13585 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsloader/InputSuppressionsLoaderXpathCorrect.xml +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppressionsloader/InputSuppressionsLoaderXpathCorrect.xml @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suppressions PUBLIC - "-//Puppy Crawl//DTD Suppressions Xpath Experimental 1.1//EN" - "http://checkstyle.sourceforge.net/dtds/suppressions_1_1_xpath_experimental.dtd"> + "-//Puppy Crawl//DTD Suppressions Xpath Experimental 1.2//EN" + "http://checkstyle.sourceforge.net/dtds/suppressions_1_2_xpath_experimental.dtd"> <suppressions> <suppress-xpath files="file1" id="id1" checks="test" query="/CLASS_DEF"/> + <suppress-xpath message="message1" query="/CLASS_DEF"/> </suppressions> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.js b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.js new file mode 100644 index 000000000..9e0fbce6c --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.js @@ -0,0 +1,7 @@ +// CS-OFF +alert( 2 === 1 ); + +// CS-ON +alert( 2 === 1 ); + +alert( 2 != 1 ); diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.properties b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.properties new file mode 100644 index 000000000..549756f6a --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.properties @@ -0,0 +1,4 @@ +# CHECKSTYLE:OFF +key1= +# CHECKSTYLE:ON +key2= diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.sql b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.sql new file mode 100644 index 000000000..662164f04 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.sql @@ -0,0 +1,5 @@ +-- CHECKSTYLE OFF + SELECT COUNT(1) FROM filters; + +-- CHECKSTYLE ON + SELECT COUNT(1) FROM checks; diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.xml new file mode 100644 index 000000000..685ec350d --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilter.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!--CS-OFF--> + +<root> + <child> + </child> + <!--CS-ON--> + <child> + </child> +</root> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterCustomMessageFormat.java b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterCustomMessageFormat.java new file mode 100644 index 000000000..d66fce649 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterCustomMessageFormat.java @@ -0,0 +1,15 @@ +package com.puppycrawl.tools.checkstyle.filters.suppresswithplaintextcommentfilter; + +public class InputSuppressWithPlainTextCommentFilterCustomMessageFormat { + + // CHECKSTYLE:OFF + private int A1; + + private static final int a1 = 5; // contains tab character + + int a2 = 100; + + // CHECKSTYLE:ON + private long a3 = 1; + +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterSuppressById.java b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterSuppressById.java new file mode 100644 index 000000000..f18d95ee8 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterSuppressById.java @@ -0,0 +1,16 @@ +package com.puppycrawl.tools.checkstyle.filters.suppresswithplaintextcommentfilter; + +public class InputSuppressWithPlainTextCommentFilterSuppressById { + + //CSOFF ignore (reason) + private int A1; + + // @cs-: ignore (reason) + private static final int a1 = 5; // contains tab character + + int a2 = 100; + //CSON ignore + + private long a3 = 1; + +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterWithCustomOnAndOffComments.java b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterWithCustomOnAndOffComments.java new file mode 100644 index 000000000..9f7067de3 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterWithCustomOnAndOffComments.java @@ -0,0 +1,14 @@ +package com.puppycrawl.tools.checkstyle.filters.suppresswithplaintextcommentfilter; + +public class InputSuppressWithPlainTextCommentFilterWithCustomOnAndOffComments { + // cs-off + // has tab here + + // cs-on + // has tab here + + + /* cs-off **/ private int b; /* cs-on **/ + + private int c; +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterWithDefaultCfg.java b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterWithDefaultCfg.java new file mode 100644 index 000000000..3a1a64d20 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/suppresswithplaintextcommentfilter/InputSuppressWithPlainTextCommentFilterWithDefaultCfg.java @@ -0,0 +1,12 @@ +package com.puppycrawl.tools.checkstyle.filters.suppresswithplaintextcommentfilter; + +public class InputSuppressWithPlainTextCommentFilterWithDefaultCfg { + // CHECKSTYLE:OFF + // has tab here + + // CHECKSTYLE:ON + // has tab here + + private int a; // CHECKSTYLE:OFF + // CHECKSTYLE:ON +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/main/InputMainConfig-non-existing-classname-ignore.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/main/InputMainConfig-non-existent-classname-ignore.xml index efee92a8d..cb1e347eb 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/main/InputMainConfig-non-existing-classname-ignore.xml +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/main/InputMainConfig-non-existent-classname-ignore.xml @@ -6,7 +6,7 @@ <module name="Checker"> <module name="TreeWalker"> - <module name="NonExistingClass"> + <module name="NonExistentClass"> <property name="severity" value="ignore"/> </module> </module> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/main/InputMainConfig-non-existing-classname.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/main/InputMainConfig-non-existent-classname.xml index 59454580b..01316ff20 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/main/InputMainConfig-non-existing-classname.xml +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/main/InputMainConfig-non-existent-classname.xml @@ -6,7 +6,7 @@ <module name="Checker"> <module name="TreeWalker"> - <module name="NonExistingClass"> + <module name="NonExistentClass"> <property name="severity" value="warning"/> </module> </module> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/utils/blockcommentposition/InputBlockCommentPositionOnAnnotationField.java b/src/test/resources/com/puppycrawl/tools/checkstyle/utils/blockcommentposition/InputBlockCommentPositionOnAnnotationField.java new file mode 100644 index 000000000..80577e124 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/utils/blockcommentposition/InputBlockCommentPositionOnAnnotationField.java @@ -0,0 +1,25 @@ +package com.puppycrawl.tools.checkstyle.utils.blockcommentposition; + +public @interface InputBlockCommentPositionOnAnnotationField { + /** + * I'm a javadoc + */ + String value() default ""; + + /** + * I'm a javadoc + */ + abstract String value1() default ""; + + /** + * I'm a javadoc + */ + @Deprecated + String value2() default ""; + + /** + * I'm a javadoc + */ + @Deprecated + abstract String value3() default ""; +} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/utils/blockcommentposition/InputBlockCommentPositionOnMethod.java b/src/test/resources/com/puppycrawl/tools/checkstyle/utils/blockcommentposition/InputBlockCommentPositionOnMethod.java index e2b5a0b8e..06e4f4d49 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/utils/blockcommentposition/InputBlockCommentPositionOnMethod.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/utils/blockcommentposition/InputBlockCommentPositionOnMethod.java @@ -22,4 +22,11 @@ public class InputBlockCommentPositionOnMethod { int method2(){ return 0; } + + /** + * I'm a javadoc + */ + java.lang.String method3(){ + return null; + } } diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLogger.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLogger.xml new file mode 100644 index 000000000..9d02b7689 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLogger.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<file name="Test.java"> +</file> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerEmpty.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerEmpty.xml new file mode 100644 index 000000000..91fd28495 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerEmpty.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerError.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerError.xml new file mode 100644 index 000000000..b3998bf18 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerError.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<file name="Test.java"> +<error line="1" column="1" severity="error" message="$0" source="com.puppycrawl.tools.checkstyle.XMLLoggerTest"/> +</file> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorModuleId.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorModuleId.xml new file mode 100644 index 000000000..cd3bec8ed --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorModuleId.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<error line="1" column="1" severity="error" message="$0" source="module"/> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorNullFileName.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorNullFileName.xml new file mode 100644 index 000000000..dae3ac4ec --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorNullFileName.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<error line="1" column="1" severity="error" message="$0" source="com.puppycrawl.tools.checkstyle.XMLLoggerTest"/> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorZeroColumn.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorZeroColumn.xml new file mode 100644 index 000000000..b0959a9c0 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerErrorZeroColumn.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<file name="Test.java"> +<error line="1" severity="error" message="$0" source="com.puppycrawl.tools.checkstyle.XMLLoggerTest"/> +</file> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException.xml new file mode 100644 index 000000000..0a5b431d7 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<exception> <![CDATA[ stackTrace example]]> </exception> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException2.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException2.xml new file mode 100644 index 000000000..9f125a0da --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException2.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<file name="Test.java"> +<exception> <![CDATA[ stackTrace example]]> </exception> +</file> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException3.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException3.xml new file mode 100644 index 000000000..a28d5156f --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerException3.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<exception> <![CDATA[ stackTrace example]]> </exception> +<file name="Test.java"> +</file> +</checkstyle> diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerExceptionNullFileName.xml b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerExceptionNullFileName.xml new file mode 100644 index 000000000..0a5b431d7 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/xmllogger/ExpectedXMLLoggerExceptionNullFileName.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<checkstyle version=""> +<exception> <![CDATA[ stackTrace example]]> </exception> +</checkstyle> |