A lot of issues for rule Java S5845 when asserting on lombok.val and a statically typed variable

I have my constants in TestUtils.java class e.g.:

public static final String USER_NAME = "joe";

And I use that in my tests:


lombok.val actualUserName = "joe";

assertEquals(actualUserName, USER_NAME);

This is producing a lot of issues for each of my assert. I think this rule is helpful and don’t want to ignore it across the board for all tests. Is there anything I can do to fix this besides suppressing per test?

Hello @obarat and welcome to the Sonarsource community!

Indeed, the rule is currently not supporting correctly lombok.val. Ticket created to fix this issue: SONARJAVA-4074.

Thanks for taking the time to report this issue.
Best,
Quentin

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