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#14092: fix UnusedLocalVariableCheck to support local…
… classes
- Loading branch information
Showing
5 changed files
with
152 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
29 changes: 29 additions & 0 deletions
29
.../checkstyle/checks/coding/unusedlocalvariable/InputUnusedLocalVariableNestedClasses4.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,29 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<property name="charset" value="UTF-8" /> | ||
<property name="severity" value="warning" /> | ||
<property name="haltOnException" value="false" /> | ||
<module name="TreeWalker"> | ||
<module name="UnusedLocalVariable"> | ||
</module> | ||
</module> | ||
</module> | ||
*/ | ||
package com.puppycrawl.tools.checkstyle.checks.coding.unusedlocalvariable; | ||
|
||
public class InputUnusedLocalVariableNestedClasses4 { | ||
int a = 12; | ||
|
||
void foo() { | ||
int a = 12; // violation, unused variable 'a' | ||
int ab = 12; // violation, unused variable 'ab' | ||
|
||
class asd { | ||
Test a = new Test() { | ||
void asd() { | ||
System.out.println(a); | ||
} | ||
}; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../checkstyle/checks/coding/unusedlocalvariable/InputUnusedLocalVariableNestedClasses5.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,38 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<property name="charset" value="UTF-8" /> | ||
<property name="severity" value="warning" /> | ||
<property name="haltOnException" value="false" /> | ||
<module name="TreeWalker"> | ||
<module name="UnusedLocalVariable"> | ||
</module> | ||
</module> | ||
</module> | ||
*/ | ||
package com.puppycrawl.tools.checkstyle.checks.coding.unusedlocalvariable; | ||
|
||
public class InputUnusedLocalVariableNestedClasses5 { | ||
int a = 12; | ||
|
||
void foo() { | ||
int a = 12; // violation, unused variable 'a' | ||
int ab = 12; // violation, unused variable 'ab' | ||
|
||
class abc { | ||
Test a = new Test() { | ||
void abc() { | ||
System.out.println(a); | ||
int abc = 10; // violation, unused variable 'abc' | ||
|
||
class def { | ||
Test abc = new Test() { | ||
void def() { | ||
System.out.println(abc); | ||
} | ||
}; | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
.../checkstyle/checks/coding/unusedlocalvariable/InputUnusedLocalVariableNestedClasses6.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,42 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<property name="charset" value="UTF-8" /> | ||
<property name="severity" value="warning" /> | ||
<property name="haltOnException" value="false" /> | ||
<module name="TreeWalker"> | ||
<module name="UnusedLocalVariable"> | ||
</module> | ||
</module> | ||
</module> | ||
*/ | ||
package com.puppycrawl.tools.checkstyle.checks.coding.unusedlocalvariable; | ||
|
||
public class InputUnusedLocalVariableNestedClasses6 { | ||
void foo() { | ||
int a = 12; // violation, unused variable 'a' | ||
int ab = 12; // violation, unused variable 'ab' | ||
|
||
class Ghi { | ||
void foo() { | ||
int a = 12; | ||
int ab = 12; // violation, unused variable 'ab' | ||
System.out.println(a); | ||
} | ||
} | ||
|
||
class Def { | ||
void foo() { | ||
int a = 12; // violation, unused variable 'a' | ||
int ab = 12; // violation, unused variable 'ab' | ||
|
||
class InnerDef { | ||
void foo() { | ||
int a = 12; // violation, unused variable 'a' | ||
int ab = 12; | ||
System.out.println(ab); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |