java:S1481 local record parameter marked as unused

  • SonarLint for Eclipse 7.1.0.39158
  • Eclipse 2021-09 (4.21.0), build id: 20210910-1417
  • openjdk version “16.0.2” 2021-07-20, OpenJDK 64-Bit Server VM Temurin-16.0.2+7 (build 16.0.2+7, mixed mode, sharing)

Similar to #43385 parameters of local records (inside a method) are marked as unused regardless of whether they are used or not and give a false-positive for java:S1481

class S1481LocalRecord {
    void test() {
        record Foo(int unused) {}
        int a = new Foo(1).unused;
        int b = new Foo(1).unused();
    }
}

Hello @Madjosz

Thanks for taking the time to report this false-positive, we should indeed not report an issue here. Ticket created: SONARJAVA-4128.

Best,
Quentin

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