IllegalType: added more classes from Collections
This commit is contained in:
parent
d3136df134
commit
0c12b97cd2
2 changed files with 15 additions and 6 deletions
17
README.md
17
README.md
|
@ -1197,16 +1197,23 @@ Checks that labels are not used.
|
|||
|
||||
#### [IllegalType](http://checkstyle.sourceforge.net/config_coding.html#IllegalType)
|
||||
|
||||
Prevents variables, parameters and method returns from being one of the following:
|
||||
Prevents use of implementation classes as variables, parameters or method returns. Use the interfaces instead.
|
||||
|
||||
* java.util.HashSet
|
||||
Prevents variables, parameters and method returns from being any of the following:
|
||||
|
||||
* java.util.ArrayDeque
|
||||
* java.util.ArrayList
|
||||
* java.util.EnumMap
|
||||
* java.util.EnumSet
|
||||
* java.util.HashMap
|
||||
* java.util.HashSet
|
||||
* java.util.IdentityHashMap
|
||||
* java.util.LinkedHashMap
|
||||
* java.util.LinkedHashSet
|
||||
* java.util.TreeSet
|
||||
* java.util.LinkedList
|
||||
* java.util.PriorityQueue
|
||||
* java.util.TreeMap
|
||||
|
||||
> TODO: add more classes from Collections
|
||||
* java.util.TreeSet
|
||||
|
||||
Valid:
|
||||
````
|
||||
|
|
|
@ -100,7 +100,9 @@
|
|||
<module name="IllegalImport"/> <!-- prevent imports from the sun.* package -->
|
||||
<module name="IllegalThrows"/> <!-- prevent generic throws (i.e. Exception, Throwable, RuntimeException) -->
|
||||
<module name="IllegalToken"/> <!-- prevents use of labels -->
|
||||
<module name="IllegalType"/> <!-- prevents variables, returns or parameters of non-interface Collections classes -->
|
||||
<module name="IllegalType"> <!-- prevents variables, returns or parameters of non-interface Collections classes -->
|
||||
<property name="illegalClassNames" value="java.util.ArrayDeque, java.util.ArrayList, java.util.EnumMap, java.util.EnumSet, java.util.HashMap, java.util.HashSet, java.util.IdentityHashMap, java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.LinkedList, java.util.PriorityQueue, java.util.TreeMap, java.util.TreeSet"/>
|
||||
</module>
|
||||
<module name="InnerAssignment"/> <!-- prevent assignments in subexpressions (i.e. while((line = read()){}) -->
|
||||
<module name="InnerTypeLast"/> <!-- inner classes appear after methods and fields -->
|
||||
<module name="InterfaceIsType"/> <!-- interface must define method not just constants -->
|
||||
|
|
Loading…
Reference in a new issue