Inspection overly aggressive?
Consider the following:
public abstract class Encoder {
public static Encoder makeStringEncoder() {
return new StringEncoder(); // I'm a naughty boy!
}
private static final class StringEncoder extends Encoder {...}
}
In Demetra 5661 the inspection "Class references subclass" flags the
indicated line.
Abstract classes offering factory methods is a common pattern and, if
the implementing class in nested, the reference seems perfectly
innocuous. It's not clear whether this is the intended behavior, an
unanticipated edge case, or a bug. So I thought I'd bring it up here.
Please sign in to leave a comment.
I think normally you would have another class EncoderFactory which contains the makeStringEncoder() method..
There was a similar issue where the concrete class was implemented as an anonymous inner class. That one has been fixed recently. So just file a JIRA request and Bas will fix it ASAP.
Here's the other issue: http://www.jetbrains.net/jira/browse/IDEADEV-7204