java:S1105 false positives

S1105 seems to produce false positives for Java records in the following layout:

    private record MyRecord(
            UUID id,
            String title,
    ) {        // Issue reported here
    }

For methods equivalent layout raises no issue:

        private Object options(
                Object arg1,
                Object arg2
        ) {

Found a similar thread: FP S1105 for java 16+ and records - #3 by Quentin - possibly SONARJAVA-4094 was not implemented fully?

While reviewing violations I noticed another false positive:

Not sure what is specific about this place though, as we have hundreds of similar methods, and the violation is reported just for this one.

Hi Gediminas, sorry about the late response.
I had a look at the issue and to me it is indeed a FP, I still have to verify what was the implementation for the previous ticket you mentioned, but one thing that I found out is that we’re missing the ( and ) parenthesis when parsing record declarations. This leads to rule S1105 not being able to recognize that there is a token before the { in examples like the one you posted here.
I created this ticket that should fix this and more issues related to record classes.
Thank you for the feedback, this will surely improve the analyzer!

1 Like

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