Merge pull request #26 from kemitix/upgrade-dependencies
Upgrade dependencies
This commit is contained in:
commit
5876d723e3
11 changed files with 149 additions and 104 deletions
91
README.md
91
README.md
|
@ -66,19 +66,11 @@ The level is now specified as a configuration parameter. See the example below.
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>sevntu-maven</id>
|
|
||||||
<name>sevntu-maven</name>
|
|
||||||
<url>http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2</url>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
````
|
````
|
||||||
|
|
||||||
## All Checks
|
## All Checks
|
||||||
|
|
||||||
Rule|Level|Source|Enabled|Suppressable
|
Rule|Level|Source|Enabled|Suppressible
|
||||||
----|-----|------|-------|------------
|
----|-----|------|-------|------------
|
||||||
[AbbreviationAsWordInName](#abbreviationaswordinname)|naming|checkstyle|Yes|
|
[AbbreviationAsWordInName](#abbreviationaswordinname)|naming|checkstyle|Yes|
|
||||||
[AbstractClassName](#abstractclassname)|naming|checkstyle|Yes|
|
[AbstractClassName](#abstractclassname)|naming|checkstyle|Yes|
|
||||||
|
@ -143,7 +135,7 @@ Rule|Level|Source|Enabled|Suppressable
|
||||||
[ForbidInstantiation](#forbidinstantiation)|unspecified|sevntu||
|
[ForbidInstantiation](#forbidinstantiation)|unspecified|sevntu||
|
||||||
[ForbidReturnInFinallyBlock](#forbidreturninfinallyblock)|complexity|sevntu|Yes|
|
[ForbidReturnInFinallyBlock](#forbidreturninfinallyblock)|complexity|sevntu|Yes|
|
||||||
[ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions)|tweaks|sevntu||
|
[ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions)|tweaks|sevntu||
|
||||||
[ForbidWildcardAsReturnType](#forbidwildcardasreturntype)|complexity|sevntu||
|
[ForbidWildcardAsReturnType](#forbidwildcardasreturntype)|complexity|sevntu|Yes|
|
||||||
[GenericWhitespace](#genericwhitespace)|layout|checkstyle|Yes|
|
[GenericWhitespace](#genericwhitespace)|layout|checkstyle|Yes|
|
||||||
[Header](#header)|layout|checkstyle|Yes|
|
[Header](#header)|layout|checkstyle|Yes|
|
||||||
[HiddenField](#hiddenfield)|tweaks|checkstyle|Yes|
|
[HiddenField](#hiddenfield)|tweaks|checkstyle|Yes|
|
||||||
|
@ -189,6 +181,7 @@ Rule|Level|Source|Enabled|Suppressable
|
||||||
[MissingSwitchDefault](#missingswitchdefault)|tweaks|checkstyle|Yes|
|
[MissingSwitchDefault](#missingswitchdefault)|tweaks|checkstyle|Yes|
|
||||||
[ModifiedControlVariable](#modifiedcontrolvariable)|tweaks|checkstyle|Yes|
|
[ModifiedControlVariable](#modifiedcontrolvariable)|tweaks|checkstyle|Yes|
|
||||||
[ModifierOrder](#modifierorder)|naming|checkstyle|Yes|
|
[ModifierOrder](#modifierorder)|naming|checkstyle|Yes|
|
||||||
|
[MoveVariableInsideIfCheck](#movevariableinsideifcheck)|tweaks|sevntu|Yes|
|
||||||
[MultipleStringLiterals](#multiplestringliterals)|naming|checkstyle|Yes|
|
[MultipleStringLiterals](#multiplestringliterals)|naming|checkstyle|Yes|
|
||||||
[MultipleVariableDeclarations](#multiplevariabledeclarations)|naming|checkstyle|Yes|
|
[MultipleVariableDeclarations](#multiplevariabledeclarations)|naming|checkstyle|Yes|
|
||||||
[MutableException](#mutableexception)|tweaks|checkstyle|Yes|
|
[MutableException](#mutableexception)|tweaks|checkstyle|Yes|
|
||||||
|
@ -2264,32 +2257,13 @@ Checks that when an exception is caught, that if it is logged then it is not als
|
||||||
Accepts `java.util.logging.Logger` and `org.slf4j.Logger`.
|
Accepts `java.util.logging.Logger` and `org.slf4j.Logger`.
|
||||||
#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html)
|
#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html)
|
||||||
|
|
||||||
Enums are considered to be of two distinct types: 'Class' or 'Value' enumerations. The distinction being that Class Enumerations have methods (other than `toString()`) defined.
|
Checks that Enum Values match the pattern: `^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$`
|
||||||
|
|
||||||
The values defined in the `enum` must match the appropriate pattern:
|
|
||||||
|
|
||||||
* Class: `^[A-Z][a-zA-Z0-9]*$`
|
|
||||||
* Value: `^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$`
|
|
||||||
|
|
||||||
The difference being that Class enumerations can't contain underscores but can include lowercase letters (after the first initial capital). Value enumerations can include underscores, but not as the first or second character.
|
|
||||||
|
|
||||||
Valid:
|
Valid:
|
||||||
````
|
````
|
||||||
enum ValidConstants {
|
enum Valid {
|
||||||
|
|
||||||
ALPHA, BETA;
|
ALPHA, BETA, GAMMA_RAY;
|
||||||
}
|
|
||||||
|
|
||||||
enum ValidClassLike {
|
|
||||||
|
|
||||||
Alpha("a"),
|
|
||||||
Beta("b");
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
ValidClassLike(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
@ -2297,19 +2271,7 @@ Invalid:
|
||||||
````
|
````
|
||||||
enum InvalidConstants {
|
enum InvalidConstants {
|
||||||
|
|
||||||
alpha, Beta, GAMMA_RAY;
|
alpha, Beta;
|
||||||
}
|
|
||||||
|
|
||||||
enum InvalidClassLike {
|
|
||||||
|
|
||||||
alpha("a"),
|
|
||||||
beta("b");
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
InvalidClassLike(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html)
|
#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html)
|
||||||
|
@ -2343,6 +2305,19 @@ try {
|
||||||
return true; // invalid
|
return true; // invalid
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html)
|
||||||
|
|
||||||
|
Prevents declaring a method from returning a wildcard type as its return value.
|
||||||
|
|
||||||
|
Valid:
|
||||||
|
````
|
||||||
|
<E> List<E> getList() {}
|
||||||
|
````
|
||||||
|
|
||||||
|
Invalid:
|
||||||
|
````
|
||||||
|
<E> List<? extends E> getList() {}
|
||||||
|
````
|
||||||
#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html)
|
#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html)
|
||||||
|
|
||||||
Prevent the placement of variables or fields after methods in an expression.
|
Prevent the placement of variables or fields after methods in an expression.
|
||||||
|
@ -2359,6 +2334,29 @@ if (getProperty() && property) {}
|
||||||
#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html)
|
#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html)
|
||||||
|
|
||||||
Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better.
|
Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better.
|
||||||
|
#### [MoveVariableInsideIfCheck](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MoveVariableInsideIfCheck.html)
|
||||||
|
|
||||||
|
Checks if a variable is declared outside an `if` block that is only used within that block.
|
||||||
|
|
||||||
|
Valid:
|
||||||
|
````
|
||||||
|
if (condition) {
|
||||||
|
String variable = input.substring(1);
|
||||||
|
return method(variable);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
````
|
||||||
|
|
||||||
|
Invalid:
|
||||||
|
````
|
||||||
|
String variable = input.substring(1);
|
||||||
|
if (condition) {
|
||||||
|
return method(variable);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
````
|
||||||
|
|
||||||
|
Example: [MoveVariableInsideIf.java](https://github.com/kemitix/kemitix-checkstyle-ruleset/blob/master/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java)
|
||||||
#### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html)
|
#### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html)
|
||||||
|
|
||||||
Checks the names of JUnit test classes. Classes checked are those that have at least one method annotated with `Test` or `org.junit.Test`.
|
Checks the names of JUnit test classes. Classes checked are those that have at least one method annotated with `Test` or `org.junit.Test`.
|
||||||
|
@ -2703,9 +2701,6 @@ Generic rule; doesn't embody a 'quality' check.
|
||||||
#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html)
|
#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html)
|
||||||
|
|
||||||
[IllegalThrows](#illegalthrows) performs a similar check.
|
[IllegalThrows](#illegalthrows) performs a similar check.
|
||||||
#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html)
|
|
||||||
|
|
||||||
Causes `NullPointerException` when used with `@Value.Immutables` from `org.immutables:value`
|
|
||||||
#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html)
|
#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html)
|
||||||
|
|
||||||
Generic rule; doesn't embody a 'quality' check.
|
Generic rule; doesn't embody a 'quality' check.
|
||||||
|
|
|
@ -66,19 +66,11 @@ The level is now specified as a configuration parameter. See the example below.
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>sevntu-maven</id>
|
|
||||||
<name>sevntu-maven</name>
|
|
||||||
<url>http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2</url>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
````
|
````
|
||||||
|
|
||||||
## All Checks
|
## All Checks
|
||||||
|
|
||||||
Rule|Level|Source|Enabled|Suppressable
|
Rule|Level|Source|Enabled|Suppressible
|
||||||
----|-----|------|-------|------------
|
----|-----|------|-------|------------
|
||||||
%s
|
%s
|
||||||
|
|
||||||
|
|
|
@ -1056,10 +1056,9 @@ rules:
|
||||||
name: ForbidWildcardAsReturnType
|
name: ForbidWildcardAsReturnType
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
level: COMPLEXITY
|
level: COMPLEXITY
|
||||||
enabled: false
|
enabled: true
|
||||||
source: SEVNTU
|
source: SEVNTU
|
||||||
uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html
|
uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html
|
||||||
reason: Causes `NullPointerException` when used with `@Value.Immutables` from `org.immutables:value`
|
|
||||||
-
|
-
|
||||||
name: LogicConditionNeedOptimization
|
name: LogicConditionNeedOptimization
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
|
@ -1499,3 +1498,10 @@ rules:
|
||||||
source: SEVNTU
|
source: SEVNTU
|
||||||
uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html
|
uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html
|
||||||
reason: "TODO: enable"
|
reason: "TODO: enable"
|
||||||
|
-
|
||||||
|
name: MoveVariableInsideIfCheck
|
||||||
|
parent: TREEWALKER
|
||||||
|
level: TWEAKS
|
||||||
|
enabled: true
|
||||||
|
source: SEVNTU
|
||||||
|
uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MoveVariableInsideIfCheck.html
|
||||||
|
|
|
@ -1,30 +1,11 @@
|
||||||
|
|
||||||
Enums are considered to be of two distinct types: 'Class' or 'Value' enumerations. The distinction being that Class Enumerations have methods (other than `toString()`) defined.
|
Checks that Enum Values match the pattern: `^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$`
|
||||||
|
|
||||||
The values defined in the `enum` must match the appropriate pattern:
|
|
||||||
|
|
||||||
* Class: `^[A-Z][a-zA-Z0-9]*$`
|
|
||||||
* Value: `^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$`
|
|
||||||
|
|
||||||
The difference being that Class enumerations can't contain underscores but can include lowercase letters (after the first initial capital). Value enumerations can include underscores, but not as the first or second character.
|
|
||||||
|
|
||||||
Valid:
|
Valid:
|
||||||
````
|
````
|
||||||
enum ValidConstants {
|
enum Valid {
|
||||||
|
|
||||||
ALPHA, BETA;
|
ALPHA, BETA, GAMMA_RAY;
|
||||||
}
|
|
||||||
|
|
||||||
enum ValidClassLike {
|
|
||||||
|
|
||||||
Alpha("a"),
|
|
||||||
Beta("b");
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
ValidClassLike(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
@ -32,18 +13,6 @@ Invalid:
|
||||||
````
|
````
|
||||||
enum InvalidConstants {
|
enum InvalidConstants {
|
||||||
|
|
||||||
alpha, Beta, GAMMA_RAY;
|
alpha, Beta;
|
||||||
}
|
|
||||||
|
|
||||||
enum InvalidClassLike {
|
|
||||||
|
|
||||||
alpha("a"),
|
|
||||||
beta("b");
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
InvalidClassLike(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
Checks if a variable is declared outside an `if` block that is only used within that block.
|
||||||
|
|
||||||
|
Valid:
|
||||||
|
````
|
||||||
|
if (condition) {
|
||||||
|
String variable = input.substring(1);
|
||||||
|
return method(variable);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
````
|
||||||
|
|
||||||
|
Invalid:
|
||||||
|
````
|
||||||
|
String variable = input.substring(1);
|
||||||
|
if (condition) {
|
||||||
|
return method(variable);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
````
|
||||||
|
|
||||||
|
Example: [MoveVariableInsideIf.java](https://github.com/kemitix/kemitix-checkstyle-ruleset/blob/master/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java)
|
|
@ -151,11 +151,4 @@
|
||||||
</plugin><!-- jacoco-maven-plugin -->
|
</plugin><!-- jacoco-maven-plugin -->
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>sevntu-maven</id>
|
|
||||||
<name>sevntu-maven</name>
|
|
||||||
<url>http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2</url>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class DefaultCheckstyleExecutor implements CheckstyleExecutor {
|
||||||
|
|
||||||
private static final String CHECKSTYLE_ARTIFACTID = "checkstyle";
|
private static final String CHECKSTYLE_ARTIFACTID = "checkstyle";
|
||||||
|
|
||||||
private static final String SEVNTU_GROUPID = "com.github.sevntu.checkstyle";
|
private static final String SEVNTU_GROUPID = "com.github.sevntu-checkstyle";
|
||||||
|
|
||||||
private static final String SEVNTU_ARTIFACTID = "sevntu-checkstyle-maven-plugin";
|
private static final String SEVNTU_ARTIFACTID = "sevntu-checkstyle-maven-plugin";
|
||||||
|
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -21,8 +21,8 @@
|
||||||
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
|
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
|
||||||
|
|
||||||
<maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
|
<maven-checkstyle-plugin.version>2.17</maven-checkstyle-plugin.version>
|
||||||
<checkstyle.version>7.6.1</checkstyle.version>
|
<checkstyle.version>7.7</checkstyle.version>
|
||||||
<sevntu.version>1.23.1</sevntu.version>
|
<sevntu.version>1.24.0</sevntu.version>
|
||||||
<mockito.version>1.10.19</mockito.version>
|
<mockito.version>1.10.19</mockito.version>
|
||||||
<assertj.version>3.8.0</assertj.version>
|
<assertj.version>3.8.0</assertj.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 Paul Campbell
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||||
|
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies
|
||||||
|
* or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.kemitix.checkstyle.regressions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regression demo for {@code MoveVariableInsideIfCheck}.
|
||||||
|
*
|
||||||
|
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||||
|
*/
|
||||||
|
class MoveVariableInsideIf {
|
||||||
|
|
||||||
|
private String input = "1";
|
||||||
|
|
||||||
|
private boolean condition;
|
||||||
|
|
||||||
|
private String method(final String variable) {
|
||||||
|
return "value";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fails if not suppressed.
|
||||||
|
*
|
||||||
|
* @return value
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("movevariableinsideif")
|
||||||
|
String invalid() {
|
||||||
|
String variable = input.substring(1);
|
||||||
|
if (condition) {
|
||||||
|
return method(variable);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrite {@link #invalid()} as this to pass.
|
||||||
|
*
|
||||||
|
* @return value
|
||||||
|
*/
|
||||||
|
String valid() {
|
||||||
|
if (condition) {
|
||||||
|
String variable = input.substring(1);
|
||||||
|
return method(variable);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -175,6 +175,7 @@
|
||||||
<module name="UniformEnumConstantName"/>
|
<module name="UniformEnumConstantName"/>
|
||||||
<module name="UselessSingleCatch"/>
|
<module name="UselessSingleCatch"/>
|
||||||
<module name="UselessSuperCtorCall"/>
|
<module name="UselessSuperCtorCall"/>
|
||||||
|
<module name="MoveVariableInsideIfCheck"/>
|
||||||
|
|
||||||
</module><!-- /TreeWalker -->
|
</module><!-- /TreeWalker -->
|
||||||
|
|
||||||
|
|
|
@ -210,6 +210,7 @@
|
||||||
<module name="EnumValueName"/>
|
<module name="EnumValueName"/>
|
||||||
<module name="ForbidCCommentsInMethods"/>
|
<module name="ForbidCCommentsInMethods"/>
|
||||||
<module name="ForbidReturnInFinallyBlock"/>
|
<module name="ForbidReturnInFinallyBlock"/>
|
||||||
|
<module name="ForbidWildcardAsReturnType"/>
|
||||||
<module name="LogicConditionNeedOptimization"/>
|
<module name="LogicConditionNeedOptimization"/>
|
||||||
<module name="MapIterationInForEachLoop"/>
|
<module name="MapIterationInForEachLoop"/>
|
||||||
<module name="NameConventionForJunit4TestClasses"/>
|
<module name="NameConventionForJunit4TestClasses"/>
|
||||||
|
@ -227,6 +228,7 @@
|
||||||
<module name="UniformEnumConstantName"/>
|
<module name="UniformEnumConstantName"/>
|
||||||
<module name="UselessSingleCatch"/>
|
<module name="UselessSingleCatch"/>
|
||||||
<module name="UselessSuperCtorCall"/>
|
<module name="UselessSuperCtorCall"/>
|
||||||
|
<module name="MoveVariableInsideIfCheck"/>
|
||||||
|
|
||||||
</module><!-- /TreeWalker -->
|
</module><!-- /TreeWalker -->
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue