[Java:S2390] Accept inline child classes

This code should not violate rule S2390:

public class Parent
    private static class Child extends Parent
    public static final Parent INSTANCE1 = new Child();

I don’t think, this really applies to what to rule aims for. And I don’t see a reason, why this should not be accepted.


Can you please split your message into several threads?
It seems to me that the following is not at all related to your report about the FP on java:S2390.


Thanks, Michael. I have fixed that. And sorry for that.

1 Like

Hello @mfroehlich,

Thanks for raising this issue, this is an interesting and quite tricky problem.

I don’t see a reason, why this should not be accepted.

My first feeling is the same. And in fact, even if one can come up with something not behaving as expected when the Child class is nested into the Parent, differentiating the case where it is or not a problem would be tricky. I therefore created a ticket (SONARJAVA-3580) to not report an issue in such situation.

If someone is interested in this topic, feel free to dig further, if you can come up with a concrete example, I would be happy to follow up on this.

Nice! Thanks.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.