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#13038: handled inner class method definition in Vari…
…ableDeclarationUsageDistanceCheck
- Loading branch information
Showing
4 changed files
with
46 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
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
30 changes: 30 additions & 0 deletions
30
...riabledeclarationusagedistance/InputVariableDeclarationUsageDistanceMethodDefinition.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,30 @@ | ||
/* | ||
VariableDeclarationUsageDistance | ||
allowedDistance = 1 | ||
ignoreVariablePattern = (default) | ||
validateBetweenScopes = true | ||
ignoreFinal = false | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.coding.variabledeclarationusagedistance; | ||
|
||
import java.util.Iterator; | ||
public class InputVariableDeclarationUsageDistanceMethodDefinition { | ||
public void method(){ | ||
int a=1; | ||
int b=2; | ||
int c=3;// violation 'Distance .* is 2.' | ||
class GeneralLogic { | ||
public <T> Iterator<T> method(T[] b) throws Exception{ | ||
if(a>0){ | ||
System.out.println(b.length); | ||
} | ||
return null; | ||
} | ||
}; | ||
System.out.print(b); | ||
System.out.print(c); | ||
} | ||
} |