AvoidDefaultSerializableInInnerClasses: enable rule
This commit is contained in:
parent
3fe3d16d42
commit
7b144fdb0a
6 changed files with 51 additions and 7 deletions
|
@ -83,7 +83,7 @@ Rule|Level|Source|Enabled|Suppressible
|
|||
[AtclauseOrder](#atclauseorder)|javadoc|checkstyle|Yes|
|
||||
[AvoidConditionInversion](#avoidconditioninversion)|complexity|sevntu||
|
||||
[AvoidConstantAsFirstOperandInCondition](#avoidconstantasfirstoperandincondition)|tweaks|sevntu|Yes|
|
||||
[AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses)|complexity|sevntu||
|
||||
[AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses)|tweaks|sevntu|Yes|
|
||||
[AvoidEscapedUnicodeCharacters](#avoidescapedunicodecharacters)|tweaks|checkstyle|Yes|
|
||||
[AvoidHidingCauseException](#avoidhidingcauseexception)|tweaks|sevntu|Yes|
|
||||
[AvoidInlineConditionals](#avoidinlineconditionals)|complexity|checkstyle|Yes|
|
||||
|
@ -2182,6 +2182,9 @@ Invalid:
|
|||
````
|
||||
if (12 == a) {}
|
||||
````
|
||||
#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html)
|
||||
|
||||
Prevent the use of default serialization methods on inner classes. If an inner class needs to implement the Serializable interface, then it *must* implement both `writeObject()` and `readObject()` methods.
|
||||
#### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html)
|
||||
|
||||
Ensures that an exception is re-thrown properly and is not swallowed by a `catch` block.
|
||||
|
@ -2758,9 +2761,6 @@ As the sevntu check are considered experimental not all those that are not enabl
|
|||
#### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html)
|
||||
|
||||
Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression).
|
||||
#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html)
|
||||
|
||||
TODO: enable
|
||||
#### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html)
|
||||
|
||||
Generic rule; doesn't embody a 'quality' check.
|
||||
|
|
|
@ -1392,11 +1392,10 @@ rules:
|
|||
-
|
||||
name: AvoidDefaultSerializableInInnerClasses
|
||||
parent: TREEWALKER
|
||||
level: COMPLEXITY
|
||||
enabled: false
|
||||
level: TWEAKS
|
||||
enabled: true
|
||||
source: SEVNTU
|
||||
uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html
|
||||
reason: "TODO: enable"
|
||||
-
|
||||
name: AvoidModifiersForTypes
|
||||
parent: TREEWALKER
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
Prevent the use of default serialization methods on inner classes. If an inner class needs to implement the Serializable interface, then it *must* implement both `writeObject()` and `readObject()` methods.
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Regression test for {@code AvoidDefaultSerializableInInnerClasses}.
|
||||
*
|
||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||
*/
|
||||
public class AvoidDefaultSerializableInInnerClasses {
|
||||
|
||||
/**
|
||||
* Inner class should not use default implementations of {@code readObject()} and {@code writeObject()}.
|
||||
*/
|
||||
@SuppressWarnings("avoiddefaultserializableininnerclasses")
|
||||
public class InnerClass implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -177,6 +177,7 @@
|
|||
<module name="com.github.sevntu.checkstyle.checks.naming.UniformEnumConstantNameCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.UselessSingleCatchCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.UselessSuperCtorCallCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.AvoidDefaultSerializableInInnerClassesCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.EmptyPublicCtorInClassCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.FinalizeImplementationCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.WhitespaceBeforeArrayInitializerCheck"/>
|
||||
|
|
|
@ -230,6 +230,7 @@
|
|||
<module name="com.github.sevntu.checkstyle.checks.naming.UniformEnumConstantNameCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.UselessSingleCatchCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.UselessSuperCtorCallCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.AvoidDefaultSerializableInInnerClassesCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.EmptyPublicCtorInClassCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.FinalizeImplementationCheck"/>
|
||||
<module name="com.github.sevntu.checkstyle.checks.coding.WhitespaceBeforeArrayInitializerCheck"/>
|
||||
|
|
Loading…
Reference in a new issue