Type can be weakened (e.g. use Collection
instead of List
here). Generalization of ConcreteCollectionCheck
#575
Labels
Collection
instead of List
here). Generalization of ConcreteCollectionCheck
#575
What it does
It should do what the IntelliJ lint does, detect code segments where one can use an interface (or superclass?) instead of the current type, because the code does not use any of the concrete types.
Locations where this might be done:
How to implement
The code tries to find types that can be replaced with either a supertype or an interface without the existing code breaking.
ArrayList
, only invokes methods that are inList
as well, ...). Here one might do a more complex implementation by checking if the use can be weakened as well. (Note: This might hurt performance)It might make sense to implement some form of utility method similar to the
findCommonParent
one, like this:Lint Name
TYPE_CAN_BE_WEAKENED
Category
oop
Example
<code>
Could be written as:
<code>
The text was updated successfully, but these errors were encountered: