diff options
author | Dmytro Kytsmen <dmitrokytsmen@gmail.com> | 2017-05-02 13:27:55 +0300 |
---|---|---|
committer | Roman Ivanov <romani@users.noreply.github.com> | 2017-05-02 06:44:26 -0700 |
commit | 15b0dbee6916a18268cc88adda9cb381a0680edc (patch) | |
tree | 668f15c212ffdfbd7bbb757903a0991bb5dbf87f /src/test/resources/com/puppycrawl | |
parent | f875cea5b1881f15153832ea383d582cb6433060 (diff) | |
download | checkstyle-15b0dbee6916a18268cc88adda9cb381a0680edc.tar.gz |
Issue #3891: Split and Organize Checkstyle inputs by Test: coding package cleanUp
Diffstat (limited to 'src/test/resources/com/puppycrawl')
-rw-r--r-- | src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/Input15Extensions.java | 36 | ||||
-rw-r--r-- | src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough.java | 524 | ||||
-rw-r--r-- | src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputSimplifyBoolean.java | 88 | ||||
-rw-r--r-- | src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputGregorianCalendar.java (renamed from src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputGregorianCalendar.java) | 2 | ||||
-rw-r--r-- | src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputImmutableSameTypeName.java | 4 |
5 files changed, 3 insertions, 651 deletions
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/Input15Extensions.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/Input15Extensions.java deleted file mode 100644 index 11ec5dfb6..000000000 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/Input15Extensions.java +++ /dev/null @@ -1,36 +0,0 @@ -// someexamples of 1.5 extensions -package com.puppycrawl.tools.checkstyle.checks.coding; - -@interface MyAnnotation1 { - String name(); - int version(); -} - -@MyAnnotation1(name = "ABC", version = 1) -public class Input15Extensions -{ - -} - -enum Enum2 -{ - A, B, C; - Enum2() {} - public String toString() { - return ""; //some custom implementation - } -} - -interface TestRequireThisEnum -{ - enum DAY_OF_WEEK - { - SUNDAY, - MONDAY, - TUESDAY, - WEDNESDAY, - THURSDAY, - FRIDAY, - SATURDAY - } -} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough.java deleted file mode 100644 index 1921aa4e9..000000000 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFallThrough.java +++ /dev/null @@ -1,524 +0,0 @@ -package com.puppycrawl.tools.checkstyle.checks.coding; - -public class InputFallThrough -{ - void method(int i, int j, boolean cond) { - while (true) { - switch (i) { - case 0: // no problem - case 1: - i++; - break; - case 2: - i++; - case 3: //fall through!!! - i++; - break; - case 4: - return; - case 5: - throw new RuntimeException(""); - case 6: - continue; - case 7: { - break; - } - case 8: { - return; - } - case 9: { - throw new RuntimeException(""); - } - case 10: { - continue; - } - case 11: { - i++; - } - case 12: //fall through!!! - if (false) - break; - else - break; - case 13: - if (true) { - return; - } - case 14: - if (true) { - return; - } else { - //do nothing - } - case 15: //fall through!!! - do { - System.identityHashCode("something"); - return; - } while(true); - case 16: - for (int j1 = 0; j1 < 10; j1++) { - String.valueOf("something"); - return; - } - case 17: - while (true) - throw new RuntimeException(""); - case 18: - while(cond) { - break; - } - case 19: //fall through!!! - try { - i++; - break; - } catch (RuntimeException e) { - break; - } catch (Error e) { - return; - } - case 20: - try { - i++; - break; - } catch (RuntimeException e) { - } catch (Error e) { - return; - } - case 21: //fall through!!! - try { - i++; - } catch (RuntimeException e) { - i--; - } finally { - break; - } - case 22: - try { - i++; - break; - } catch (RuntimeException e) { - i--; - break; - } finally { - i++; - } - case 23: - switch (j) { - case 1: - continue; - case 2: - return; - default: - return; - } - case 24: - switch (j) { - case 1: - continue; - case 2: - break; - default: - return; - } - default: //fall through!!! - // this is the last label - i++; - } - } - } - - - - /* Like above, but all fall throughs with relief comment */ - void methodFallThru(int i, int j, boolean cond) { - while (true) { - switch (i) { - case -1: // FALLTHRU - - case 0: // no problem - case 1: - i++; - break; - case 2: - i++; - // fallthru - case 3: - i++; - break; - case 4: - return; - case 5: - throw new RuntimeException(""); - case 6: - continue; - case 7: { - break; - } - case 8: { - return; - } - case 9: { - throw new RuntimeException(""); - } - case 10: { - continue; - } - case 11: { - i++; - } - // fallthru - case 12: - if (false) - break; - else - break; - case 13: - if (true) { - return; - } - case 14: - if (true) { - return; - } else { - //do nothing - } - // fallthru - case 15: - do { - System.identityHashCode("something"); - return; - } while(true); - case 16: - for (int j1 = 0; j1 < 10; j1++) { - String.valueOf("something"); - return; - } - case 17: - while (cond) - throw new RuntimeException(""); - case 18: - while(cond) { - break; - } - // fallthru - case 19: - try { - i++; - break; - } catch (RuntimeException e) { - break; - } catch (Error e) { - return; - } - case 20: - try { - i++; - break; - } catch (RuntimeException e) { - } catch (Error e) { - return; - } - // fallthru - case 21: - try { - i++; - } catch (RuntimeException e) { - i--; - } finally { - break; - } - case 22: - try { - i++; - break; - } catch (RuntimeException e) { - i--; - break; - } finally { - i++; - } - - case 23: - switch (j) { - case 1: - continue; - case 2: - return; - default: - return; - } - case 24: - i++; - /* fallthru */ case 25: - i++; - break; - - case 26: - switch (j) { - case 1: - continue; - case 2: - break; - default: - return; - } - // fallthru - default: - // this is the last label - i++; - // fallthru - } - } - } - - /* Test relief comment. */ - void methodFallThruCC(int i, int j, boolean cond) { - while (true) { - switch (i){ - case 0: - i++; // fallthru - - case 1: - i++; - // fallthru - case 2: { - i++; - } - // fallthru - case 3: - i++; - /* fallthru */case 4: - break; - case 5: - i++; - // fallthru - } - } - } - - /* Like above, but C-style comments. */ - void methodFallThruC(int i, int j, boolean cond) { - while (true) { - switch (i){ - case 0: - i++; /* fallthru */ - - case 1: - i++; - /* fallthru */ - case 2: - i++; - /* fallthru */case 3: - break; - case 4: - i++; - /* fallthru */ - } - } - } - - /* Like above, but C-style comments with no spaces. */ - void methodFallThruC2(int i, int j, boolean cond) { - while (true) { - switch (i){ - case 0: - i++; /*fallthru*/ - - case 1: - i++; - /*fallthru*/ - case 2: - i++; - /*fallthru*/case 3: - break; - case 4: - i++; - /*fallthru*/ - } - } - } - - /* C-style comments with other default fallthru-comment. */ - void methodFallThruCOtherWords(int i, int j, boolean cond) { - while (true) { - switch (i){ - case 0: - i++; /* falls through */ - - case 1: - i++; - /* falls through */ - case 2: - i++; - /* falls through */case 3: - break; - case 4: - i++; - /* falls through */ - } - } - } - - /* C-style comments with custom fallthru-comment. */ - void methodFallThruCCustomWords(int i, int j, boolean cond) { - while (true) { - switch (i){ - case 0: - i++; /* Continue with next case */ - - case 1: - i++; - /* Continue with next case */ - case 2: - i++; - /* Continue with next case */case 3: - break; - case 4: - i++; - /* Continue with next case */ - } - } - } - - void methodFallThruLastCaseGroup(int i, int j, boolean cond) { - while (true) { - switch (i){ - case 0: - i++; // fallthru - } - switch (i){ - case 0: - i++; - // fallthru - } - switch (i){ - case 0: - i++; - /* fallthru */ } - } - } - - void method1472228(int i) { - switch(i) { - case 2: - // do nothing - break; - default: - } - } - - void nestedSwitches() { - switch (hashCode()) { - case 1: - switch (hashCode()) { // causing NullPointerException in the past - case 1: - } - default: // violation - no fall through comment - } - } - - void nextedSwitches2() { - switch(hashCode()) { - case 1: - switch(hashCode()){} - case 2: - System.lineSeparator(); - break; - } - } - - void ifWithoutBreak() { - switch(hashCode()) { - case 1: - if (true) { - System.lineSeparator(); - } - case 2: - System.lineSeparator(); - break; - } - } - - void noCommentAtTheEnd() { - switch(hashCode()) { - case 1: System.lineSeparator(); - - case 2: - System.lineSeparator(); - break; - } - } - - void tryResource() throws Exception { - switch (hashCode()) { - case 1: - try (final Resource resource = new Resource()) { - return; - } - case 2: - try (final Resource resource = new Resource()) { - return; - } - finally { - return; - } - case 3: - try (final Resource resource = new Resource()) { - return; - } - catch (Exception ex) { - return; - } - case 4: - try (final Resource resource = new Resource()) { - } - finally { - return; - } - case 5: - try (final Resource resource = new Resource()) { - return; - } - finally { - } - case 6: - try (final Resource resource = new Resource()) { - } - catch (Exception ex) { - return; - } - // fallthru - case 7: - try (final Resource resource = new Resource()) { - } - // fallthru - case 8: - try (final Resource resource = new Resource()) { - } - finally { - } - // fallthru - case 9: - try (final Resource resource = new Resource()) { - } - catch (Exception ex) { - } - // fallthru - case 10: - try (final Resource resource = new Resource()) { - return; - } - catch (Exception ex) { - } - // fallthru - default: - break; - } - } - - private static class Resource implements AutoCloseable { - @Override - public void close() throws Exception { - } - } -} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputSimplifyBoolean.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputSimplifyBoolean.java deleted file mode 100644 index 36d3b818b..000000000 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputSimplifyBoolean.java +++ /dev/null @@ -1,88 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// Test case file for checkstyle. -// Created: 2001 -//////////////////////////////////////////////////////////////////////////////// -package com.puppycrawl.tools.checkstyle.checks.coding; - -/** - Contains boolean logic that can be simplified. - - @author lkuehne - */ -public class InputSimplifyBoolean -{ - - public static boolean isOddMillis() - { - boolean even = System.currentTimeMillis() % 2 == 0; - - // can be simplified to "if (even)" - if (even == true) { - return false; - } - else { - return true; - } - // return can be simplified to "return !even" - } - - public static boolean isOddMillis2() - { - boolean even = System.currentTimeMillis() % 2 == 0; - // can be simplified to "return !even" - if (!even) - return true; - else - return false; - } - - public static boolean giveMeTrue() - { - boolean tt = isOddMillis() || true; - boolean ff = isOddMillis() && false; - return !false || (true != false); - } - - public void tryToProvokeNPE() - { - if (true) { - } - else { - } - - if (true) { - return; - } - else { - return; - } - } - - public boolean ifNoElse() - { - if (isOddMillis()) { - return true; - } - return false; - } - - boolean a() { - boolean asd = false; - boolean dasa = true; - - if (asd) { - return true; - } else { - return dasa; - } - } - - boolean b() { - boolean asd = false; - - if(asd); - else; - - return true; - } -} diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputGregorianCalendar.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputGregorianCalendar.java index 4b804a443..629dc3bdd 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputGregorianCalendar.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputGregorianCalendar.java @@ -1,4 +1,4 @@ -package com.puppycrawl.tools.checkstyle.checks.coding; +package com.puppycrawl.tools.checkstyle.checks.design; public class InputGregorianCalendar { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputImmutableSameTypeName.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputImmutableSameTypeName.java index 7c815f5e4..0b06a7635 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputImmutableSameTypeName.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/design/InputImmutableSameTypeName.java @@ -1,12 +1,12 @@ package com.puppycrawl.tools.checkstyle.checks.design; -import com.puppycrawl.tools.checkstyle.checks.coding.InputGregorianCalendar; +import com.puppycrawl.tools.checkstyle.checks.design.InputGregorianCalendar; import com.puppycrawl.tools.checkstyle.checks.design.InetSocketAddress; public final class InputImmutableSameTypeName { public final java.util.GregorianCalendar calendar = null; public final InputGregorianCalendar calendar2 = null; - public final com.puppycrawl.tools.checkstyle.checks.coding.InputGregorianCalendar calendar3 = null; + public final com.puppycrawl.tools.checkstyle.checks.design.InputGregorianCalendar calendar3 = null; public final InetSocketAddress address = null; public final java.net.InetSocketAddress adr = null; } |