Detect classes that do not use inheritance or inner classes that should be static
#560
Labels
enhancement
New feature or request
low-priority
new-lint
A new lint.
unresolved
Some decisions have not been made yet or it is not obvious what should be detected.
What it does
One can nest a class in another class like this:
If the class is not
static
, it will extend the outer class, making the non-static fields and methods accessible.In most submissions this behaviour is not intentional and therefore it makes sense to detect these cases.
Problems with this check:
After implementing this, it should be easy to find classes that inherit from another class, but do not need to inherit from it. Note: I do not think that this happens very often, that is why this issue is marked as
low-priority
Things to be careful about with the inheritance thing:
Parent parent = new Child()
Lint Name
INNER_CLASS_SHOULD_BE_STATIC,CLASS_SHOULD_NOT_INHERIT
Category
oop
Example
<code>
Could be written as:
<code>
The text was updated successfully, but these errors were encountered: