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
9 changed files
with
292 additions
and
1 deletion.
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
48 changes: 48 additions & 0 deletions
48
...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,48 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<module name="TreeWalker"> | ||
<module name="HideUtilityClassConstructor"> | ||
<property name="ignoreAnnotatedBy" value="SkipMe, java.lang.Deprecated" /> | ||
</module> | ||
</module> | ||
</module> | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.design.hideutilityclassconstructor; | ||
|
||
// xdoc section -- start | ||
class Example2 { // violation | ||
|
||
public Example2() { | ||
|
||
} | ||
|
||
public static void fun() { | ||
|
||
} | ||
} | ||
|
||
@SkipMe | ||
class IgnoredClass1 { // ok, ignored by annotation | ||
public IgnoredClass1() { | ||
|
||
} | ||
|
||
public static void fun() { | ||
|
||
} | ||
} | ||
|
||
@java.lang.Deprecated | ||
class IgnoredClass2 { // ok, ignored by annotation | ||
public IgnoredClass2() { | ||
|
||
} | ||
|
||
public static void fun() { | ||
|
||
} | ||
} | ||
|
||
@interface SkipMe {} | ||
// xdoc section -- end |
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