-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #14424: Add option to skip validation based on list of annotations
- Loading branch information
Showing
11 changed files
with
441 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...esign/hideutilityclassconstructor/InputHideUtilityClassConstructorIgnoreAnnotationBy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
HideUtilityClassConstructor | ||
ignoreAnnotatedBy = Skip, SkipWithParam, SkipWithAnnotationAsParam | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.design.hideutilityclassconstructor; | ||
|
||
@Skip | ||
public class InputHideUtilityClassConstructorIgnoreAnnotationBy { | ||
public static void func() {} | ||
} | ||
|
||
@SkipWithParam(name = "tool1") | ||
class ToolClass1 { | ||
public static void func() {} | ||
} | ||
|
||
@SkipWithAnnotationAsParam(skip = @Skip) | ||
class ToolClass2 { | ||
public static void func() {} | ||
} | ||
|
||
@CommonAnnot | ||
@Skip | ||
class ToolClass3 { | ||
public static void func() {} | ||
} | ||
|
||
@CommonAnnot // violation | ||
class ToolClass4 { | ||
public static void func() {} | ||
} | ||
|
||
|
||
@interface Skip {} | ||
|
||
@interface SkipWithParam { | ||
String name(); | ||
} | ||
|
||
@interface SkipWithAnnotationAsParam { | ||
Skip skip(); | ||
} | ||
|
||
@interface CommonAnnot {} |
19 changes: 19 additions & 0 deletions
19
...lassconstructor/InputHideUtilityClassConstructorIgnoreAnnotationByFullyQualifiedName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
HideUtilityClassConstructor | ||
ignoreAnnotatedBy = java.lang.Deprecated | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.design.hideutilityclassconstructor; | ||
|
||
@Deprecated // violation | ||
public class InputHideUtilityClassConstructorIgnoreAnnotationByFullyQualifiedName { | ||
public static void func() {} | ||
} | ||
|
||
@java.lang.Deprecated | ||
class DeprecatedClass { | ||
public static void func() {} | ||
} | ||
|
||
@interface Deprecated {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...s/com/puppycrawl/tools/checkstyle/checks/design/hideutilityclassconstructor/Example2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<module name="TreeWalker"> | ||
<module name="HideUtilityClassConstructor"> | ||
<property name="ignoreAnnotatedBy" | ||
value="SpringBootApplication, java.lang.Deprecated" /> | ||
</module> | ||
</module> | ||
</module> | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.design.hideutilityclassconstructor; | ||
|
||
// xdoc section -- start | ||
@java.lang.Deprecated | ||
class Example2 { // OK, skipped by annotation | ||
|
||
public Example2() { | ||
} | ||
|
||
public static void fun() { | ||
} | ||
} | ||
|
||
class Foo2 { | ||
|
||
private Foo2() { | ||
} | ||
|
||
static int n; | ||
} | ||
|
||
class Bar2 { | ||
|
||
protected Bar2() { | ||
// prevents calls from subclass | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
|
||
@SpringBootApplication | ||
class ApplicationClass2 { // OK, skipped by annotation | ||
|
||
static float f; | ||
} | ||
// xdoc section -- end | ||
@interface SpringBootApplication {} |
46 changes: 46 additions & 0 deletions
46
...s/com/puppycrawl/tools/checkstyle/checks/design/hideutilityclassconstructor/Example3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<module name="TreeWalker"> | ||
<module name="HideUtilityClassConstructor"> | ||
<property name="ignoreAnnotatedBy" | ||
value="SpringBootApplication, Deprecated" /> | ||
</module> | ||
</module> | ||
</module> | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.design.hideutilityclassconstructor; | ||
|
||
// xdoc section -- start | ||
@java.lang.Deprecated // violation | ||
class Example3 { | ||
|
||
public Example3() { | ||
} | ||
|
||
public static void fun() { | ||
} | ||
} | ||
|
||
class Foo3 { | ||
|
||
private Foo3() { | ||
} | ||
|
||
static int n; | ||
} | ||
|
||
class Bar3 { | ||
|
||
protected Bar3() { | ||
// prevents calls from subclass | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
|
||
@SpringBootApplication | ||
class ApplicationClass3 { // OK, skipped by annotation | ||
|
||
static float f; | ||
} | ||
// xdoc section -- end |
Oops, something went wrong.