aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle/filters
diff options
context:
space:
mode:
authorIvan Sopov <sopov.ivan@gmail.com>2014-02-19 22:34:10 +0200
committerIvan Sopov <sopov.ivan@gmail.com>2014-03-04 19:18:11 +0200
commitf1efb27670a93690577f1bae17fc9dcbd88a795d (patch)
treeb4c1b1405c4b2cfb30bb3f3e6429c4ecd89798a2 /src/test/resources/com/puppycrawl/tools/checkstyle/filters
parent1cdaeaaa4fbf02a7388f1fcbea1c86ef0ea32fed (diff)
downloadcheckstyle-f1efb27670a93690577f1bae17fc9dcbd88a795d.tar.gz
moving to standard directory layout
Diffstat (limited to 'src/test/resources/com/puppycrawl/tools/checkstyle/filters')
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressWarningsFilter.java59
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressWithNearbyCommentFilter.java77
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressionCommentFilter.java83
3 files changed, 219 insertions, 0 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressWarningsFilter.java b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressWarningsFilter.java
new file mode 100644
index 000000000..a1e907459
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressWarningsFilter.java
@@ -0,0 +1,59 @@
+////////////////////////////////////////////////////////////////////////////////
+// Test case file for checkstyle.
+////////////////////////////////////////////////////////////////////////////////
+
+package com.puppycrawl.tools.checkstyle.filters;
+
+/**
+ * Test input for using comments to suppress errors.
+ *
+ * @author Trevor Robinson
+ **/
+@SuppressWarnings("foo") // coverage: no following AST
+class InputSuppressWarningsFilter
+{
+ // AST coverage
+ @SuppressWarnings("foo") interface I { }
+ @SuppressWarnings("foo") enum E { }
+ @SuppressWarnings("foo") InputSuppressWarningsFilter() { }
+
+ // include a non-checkstyle suppression; suppression on same line
+ @SuppressWarnings("unused") private int I; // should fail MemberNameCheck
+ @SuppressWarnings({"membername"})
+ private int J; // should NOT fail MemberNameCheck
+ private int K; // should fail MemberNameCheck
+
+ // DO NOT REFORMAT: L and X should be on the same line
+ @SuppressWarnings(value="membername")
+ private int L; private int X; // L should NOT fail, X should
+
+ // test "checkstyle:" prefix
+ @SuppressWarnings("checkstyle:constantname")
+ private static final int m = 0; // should NOT fail ConstantNameCheck
+ private static final int n = 0; // should fail ConstantNameCheck
+
+ // test explicit warning alias
+ @SuppressWarnings("paramnum")
+ // should NOT fail ParameterNumberCheck
+ public void needsLotsOfParameters(@SuppressWarnings("unused") int a,
+ int b, int c, int d, int e, int f, int g, int h)
+ {
+ @SuppressWarnings("unused") int z;
+ try {
+ }
+ catch (Exception ex) {
+ // should fail IllegalCatchCheck
+ }
+ }
+
+ // test fully qualified annotation name
+ @java.lang.SuppressWarnings("illegalcatch")
+ public void needsToCatchException()
+ {
+ try {
+ }
+ catch (Exception ex) {
+ // should NOT fail IllegalCatchCheck
+ }
+ }
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressWithNearbyCommentFilter.java b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressWithNearbyCommentFilter.java
new file mode 100644
index 000000000..0223827e2
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressWithNearbyCommentFilter.java
@@ -0,0 +1,77 @@
+////////////////////////////////////////////////////////////////////////////////
+// Test case file for checkstyle.
+////////////////////////////////////////////////////////////////////////////////
+
+package com.puppycrawl.tools.checkstyle.filters;
+
+/**
+ * Test input for using comments to suppress errors.
+ *
+ * @author Mick Killianey
+ */
+class InputSuppressWithNearbyCommentFilter
+{
+ private int A1; // SUPPRESS CHECKSTYLE MemberNameCheck
+ private int A2; /* SUPPRESS CHECKSTYLE MemberNameCheck */
+ /* SUPPRESS CHECKSTYLE MemberNameCheck */ private int A3;
+
+ private int B1; // SUPPRESS CHECKSTYLE MemberNameCheck
+ private int B2; /* SUPPRESS CHECKSTYLE MemberNameCheck */
+ /* SUPPRESS CHECKSTYLE MemberNameCheck */ private int B3;
+
+ private int C1;
+ // ALLOW MemberName ON NEXT LINE
+ private int C2;
+ private int C3;
+
+ private int D1;
+ private int D2;
+ // ALLOW MemberName ON PREVIOUS LINE
+ private int D3;
+
+ private static final int e1 = 0;
+ private int E2;
+ private int E3; // ALLOW ConstantName UNTIL THIS LINE+2
+ private static final int e4 = 0;
+ private int E5;
+ private static final int e6 = 0;
+ private int E7;
+ private int E8; /* ALLOW MemberName UNTIL THIS LINE-3 */
+ private static final int e9 = 0;
+
+ // ALLOW Unused UNTIL THIS LINE+5
+ public static void doit1(int aInt) // this is +1
+ {
+ }
+
+ public static void doit2(int aInt) // this is +5
+ {
+ }
+
+ public static void doit3(int aInt) // this is +9
+ {
+ }
+
+ public void doit4()
+ {
+ try {
+ // blah blah blah
+ for(int i = 0; i < 10; i++) {
+ // blah blah blah
+ while(true) {
+ try {
+ // blah blah blah
+ } catch(Exception e) {
+ // bad bad bad
+ } catch (Throwable t) {
+ // ALLOW CATCH Throwable BECAUSE I threw this together.
+ }
+ }
+ // blah blah blah
+ }
+ // blah blah blah
+ } catch(Exception ex) {
+ // ALLOW CATCH Exception BECAUSE I am an exceptional person.
+ }
+ }
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressionCommentFilter.java b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressionCommentFilter.java
new file mode 100644
index 000000000..de8dc677e
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/filters/InputSuppressionCommentFilter.java
@@ -0,0 +1,83 @@
+////////////////////////////////////////////////////////////////////////////////
+// Test case file for checkstyle.
+////////////////////////////////////////////////////////////////////////////////
+
+package com.puppycrawl.tools.checkstyle.filters;
+
+/**
+ * Test input for using comments to suppress errors.
+ * @author Rick Giles
+ **/
+class InputSuppressionCommentFilter
+{
+ private int I;
+
+ /* CHECKSTYLE:OFF */
+ private int J;
+ /* CHECKSTYLE:ON */
+
+ private int K;
+
+ //CSOFF: MemberNameCheck|ConstantNameCheck
+ private int L;
+ private static final int m = 0;
+ /*
+ * CSON: MemberNameCheck
+ */
+ private int M2;
+ private static final int n = 0;
+ //CSON: ConstantNameCheck
+
+ //CS_OFF
+ private int P;
+ //CS_ON
+
+ private int Q;
+
+ //CS_OFF: ConstantNameCheck
+ private int R;
+ private static final int s = 0;
+ //CS_ON
+
+ //CHECKSTYLE:OFF
+ private int T;
+ //CHECKSTYLE:ON
+
+ //UNUSED OFF: aInt
+ public static void doit1(int aInt)
+ {
+ }
+ //UNUSED ON: aInt
+ public static void doit2(int aInt)
+ {
+ }
+
+ public void doit3()
+ {
+ try {
+ // lots of code omitted
+ for(int i = 0; i < 10; i++) {
+ // more code omitted
+ while(true) {
+ try {
+ //CHECKSTYLE:OFF
+ } catch(Exception e) {
+ //CHECKSTYLE:ON
+ }
+ }
+ // code omitted
+ }
+ //CHECKSTYLE:OFF
+ } catch(Exception ex) {
+ //CHECKSTYLE:ON
+ }
+
+ try{
+ //IllegalCatchCheck OFF: Exception
+ } catch(RuntimeException ex){
+ } catch(Exception ex){
+ //IllegalCatchCheck ON: Exception
+ }
+ }
+
+}