forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#11340: Add ignoreAnnotatedBy property to ParameterNu…
…mberCheck
- Loading branch information
Showing
10 changed files
with
405 additions
and
6 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
26 changes: 26 additions & 0 deletions
26
...athfilter/parameternumber/SuppressionXpathRegressionParameterNumberIgnoreAnnotatedBy.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,26 @@ | ||
package org.checkstyle.suppressionxpathfilter.parameternumber; | ||
|
||
public class SuppressionXpathRegressionParameterNumberIgnoreAnnotatedBy { | ||
static class InnerClass { | ||
static { | ||
new Object() { | ||
void method() { | ||
if (true) { | ||
new Object() { | ||
@MyAnno | ||
void ignoredMethod(int a, @MyAnno int b, int c) { | ||
|
||
} | ||
|
||
void checkedMethod(int a, @MyAnno int b, int c) { // warn | ||
|
||
} | ||
}; | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@interface MyAnno {} | ||
} |
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
115 changes: 115 additions & 0 deletions
115
.../tools/checkstyle/checks/sizes/parameternumber/InputParameterNumberIgnoreAnnotatedBy.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,115 @@ | ||
/* | ||
ParameterNumber | ||
max = 2 | ||
ignoreAnnotatedBy = MyAnno, Session | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.sizes.parameternumber; | ||
|
||
public class InputParameterNumberIgnoreAnnotatedBy { | ||
@MyAnno | ||
InputParameterNumberIgnoreAnnotatedBy(int a, int b, int c) {} | ||
|
||
void method1(int a, int b) {} | ||
|
||
@MyAnno | ||
void method2(int a, int b, int c) {} | ||
|
||
@Session(uid = "Y2K") | ||
void method3(int a, int b, int c, int d) {} | ||
|
||
@Wawa | ||
void method5(int a, int b, int c) { // violation, 'More than 2 parameters (found 3).' | ||
} | ||
|
||
@Wawa | ||
void method6(int a, int b) {} | ||
|
||
|
||
void method7(int a, int b, int c, int d) { // violation, 'More than 2 parameters (found 4).' | ||
} | ||
|
||
class InnerClass extends InputParameterNumberIgnoreAnnotatedBy { | ||
@Override | ||
void method2(int a, int b, int c) { // violation, 'More than 2 parameters (found 3).' | ||
int d = a + c; | ||
} | ||
|
||
InnerClass(int a, int b) { | ||
super(1, 2, 3); | ||
} | ||
|
||
InnerClass(int a, int b, int c, int d) { // violation, 'More than 2 parameters (found 4).' | ||
super(1, 2, 3); | ||
} | ||
} | ||
|
||
static class Very { | ||
static class Deep { | ||
static class Rabbit { | ||
enum Colors { | ||
GOLDEN(1, 2, 3) { | ||
void jump(int a, int b) {} | ||
@MyAnno | ||
void roll(int a, int b, int c) {} | ||
|
||
// violation below, 'More than 2 parameters (found 3).' | ||
void loaf(int a, int b, int c) {} | ||
}; | ||
|
||
@Wawa | ||
private Colors(@MyAnno int a, int b, int c) {} | ||
// violation above, 'More than 2 parameters (found 3).' | ||
|
||
@Session(uid = ":D") | ||
private Colors(@Wawa int a, @Wawa int b, @Wawa int c, @Wawa int d) {} | ||
|
||
private Colors(int a) {} | ||
} | ||
static class Hole { | ||
static { | ||
new Object() { | ||
@MyAnno @Session(uid = "G0F") | ||
void method1(int a, int b, int c) {} | ||
|
||
// violation below, 'More than 2 parameters (found 4).' | ||
void method3(@MyAnno int a, @MyAnno int b, @MyAnno int c, int d) {} | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Wawa | ||
@MyAnno | ||
void method8(int a, int b, int c) { | ||
} | ||
|
||
@Session(uid = "H1") @Bit | ||
@Wawa | ||
void method9(int a, int b, int c) { | ||
} | ||
|
||
@Bit | ||
@Wawa | ||
void method10(int a, int b, int c) { // violation, 'More than 2 parameters (found 3).' | ||
} | ||
|
||
interface Reader { | ||
void method1 (int a, int b); | ||
|
||
@MyAnno | ||
void method2 (int a, int b, int c); | ||
|
||
void method3 (int a, int b, int c); // violation, 'More than 2 parameters (found 3).' | ||
} | ||
|
||
@interface Wawa {} | ||
@interface Bit {} | ||
@interface MyAnno {} | ||
@interface Session { | ||
String uid(); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...s/sizes/parameternumber/InputParameterNumberIgnoreAnnotatedByFullyQualifiedClassName.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,62 @@ | ||
/* | ||
ParameterNumber | ||
max = 2 | ||
ignoreAnnotatedBy = java.lang.Deprecated, InnerClass.InnerAnno, Session | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.sizes.parameternumber; | ||
|
||
public class InputParameterNumberIgnoreAnnotatedByFullyQualifiedClassName { | ||
@java.lang.Deprecated | ||
void method3(int a, int b, int c) {} | ||
|
||
@Deprecated | ||
void method4(int a, int b, int c) {} // violation, 'More than 2 parameters (found 3).' | ||
|
||
void method5(int a, int b, int c) {} // violation, 'More than 2 parameters (found 3).' | ||
|
||
@Session | ||
void method6(int a, int b, int c) {} | ||
|
||
@InputParameterNumberIgnoreAnnotatedByFullyQualifiedClassName.Session | ||
void method7(int a, int b, int c) {} // violation, 'More than 2 parameters (found 3).' | ||
|
||
@com.puppycrawl.tools.checkstyle.checks.sizes.parameternumber | ||
.InputParameterNumberIgnoreAnnotatedByFullyQualifiedClassName.Session | ||
void method8(int a, int b, int c) {} // violation, 'More than 2 parameters (found 3).' | ||
|
||
@com.puppycrawl.tools.checkstyle.checks.sizes.parameternumber | ||
.InputParameterNumberIgnoreAnnotatedByFullyQualifiedClassName.Session | ||
void method8(int a, int b) {} | ||
|
||
private static class InnerClass { | ||
private @interface InnerAnno {} | ||
|
||
@InnerClass.InnerAnno | ||
void method1(int a, int b, int c) { | ||
} | ||
|
||
@InnerAnno | ||
void method2(int a, int b, int c) { // violation, 'More than 2 parameters (found 3).' | ||
} | ||
|
||
@Bit | ||
void method3(int a, int b, int c) { // violation, 'More than 2 parameters (found 3).' | ||
} | ||
|
||
@InnerAnno | ||
void method2(int a, int b) { | ||
} | ||
|
||
@Bit | ||
void method3(int a, int b) { | ||
} | ||
|
||
void method4(int a, int b) { | ||
} | ||
} | ||
|
||
@interface Session {} | ||
@interface Bit{} | ||
} |
Oops, something went wrong.