builder: ExplicitInitilization only applies to object references
This commit is contained in:
parent
96381c9c90
commit
4cc70343be
7 changed files with 19 additions and 16 deletions
|
@ -8,6 +8,7 @@ CHANGELOG
|
||||||
* Upgrade sevntu to 1.24.0
|
* Upgrade sevntu to 1.24.0
|
||||||
* Add Rule: MoveVariableInsideIf
|
* Add Rule: MoveVariableInsideIf
|
||||||
* Add Rule: ForbidWildcardAsReturnType
|
* Add Rule: ForbidWildcardAsReturnType
|
||||||
|
* Modify Rule: ExplicitInitialization only applies to objects
|
||||||
* Add Wercker CI
|
* Add Wercker CI
|
||||||
* Add Shippable CI
|
* Add Shippable CI
|
||||||
|
|
||||||
|
|
|
@ -903,13 +903,15 @@ Checks that when a class overrides the `equals()` method, that it also overrides
|
||||||
Limits the number of executable statements in a method to 30.
|
Limits the number of executable statements in a method to 30.
|
||||||
#### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization)
|
#### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization)
|
||||||
|
|
||||||
Checks that fields are not being explicitly initialised to their already default value.
|
Checks that object fields are not being explicitly initialised to their already default value.
|
||||||
|
|
||||||
|
Does not check primitive field types.
|
||||||
|
|
||||||
Valid:
|
Valid:
|
||||||
````
|
````
|
||||||
class Valid {
|
class Valid {
|
||||||
|
|
||||||
private int foo;
|
private int foo = 0;
|
||||||
|
|
||||||
private Object bar;
|
private Object bar;
|
||||||
}
|
}
|
||||||
|
@ -919,7 +921,7 @@ Invalid:
|
||||||
````
|
````
|
||||||
class Invalid {
|
class Invalid {
|
||||||
|
|
||||||
private int foo = 0;
|
private Integer foo = 0;
|
||||||
|
|
||||||
private Object bar = null;
|
private Object bar = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,6 +275,8 @@ rules:
|
||||||
enabled: true
|
enabled: true
|
||||||
source: CHECKSTYLE
|
source: CHECKSTYLE
|
||||||
uri: http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization
|
uri: http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization
|
||||||
|
properties:
|
||||||
|
onlyObjectReferences: true
|
||||||
-
|
-
|
||||||
name: FallThrough
|
name: FallThrough
|
||||||
parent: TREEWALKER
|
parent: TREEWALKER
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
|
|
||||||
Checks that fields are not being explicitly initialised to their already default value.
|
Checks that object fields are not being explicitly initialised to their already default value.
|
||||||
|
|
||||||
|
Does not check primitive field types.
|
||||||
|
|
||||||
Valid:
|
Valid:
|
||||||
````
|
````
|
||||||
class Valid {
|
class Valid {
|
||||||
|
|
||||||
private int foo;
|
private int foo = 0;
|
||||||
|
|
||||||
private Object bar;
|
private Object bar;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +17,7 @@ Invalid:
|
||||||
````
|
````
|
||||||
class Invalid {
|
class Invalid {
|
||||||
|
|
||||||
private int foo = 0;
|
private Integer foo = 0;
|
||||||
|
|
||||||
private Object bar = null;
|
private Object bar = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,8 @@ package net.kemitix.checkstyle.regressions;
|
||||||
@SuppressWarnings("hideutilityclassconstructor")
|
@SuppressWarnings("hideutilityclassconstructor")
|
||||||
class ExplicitInitialization {
|
class ExplicitInitialization {
|
||||||
|
|
||||||
/**
|
|
||||||
* This will become valid in next release.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("explicitinitialization")
|
|
||||||
private boolean validBoolean = false;
|
private boolean validBoolean = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* This will become valid in next release.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("explicitinitialization")
|
|
||||||
private int validInt = 0;
|
private int validInt = 0;
|
||||||
|
|
||||||
private String validString = "";
|
private String validString = "";
|
||||||
|
|
|
@ -50,7 +50,9 @@
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck">
|
||||||
|
<property name="onlyObjectReferences" value="true"/>
|
||||||
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck"/>
|
||||||
|
|
|
@ -69,7 +69,9 @@
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.ExecutableStatementCountCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.ExecutableStatementCountCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck">
|
||||||
|
<property name="onlyObjectReferences" value="true"/>
|
||||||
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck"/>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
|
<module name="com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck"/>
|
||||||
|
|
Loading…
Reference in a new issue