Skip to content

False detection for rule "The variable is never reassigned and can be 'final'" bis #122

@errorscript

Description

@errorscript

Describe the bug
final keyword is not recognized when using instanceof pattern

To Reproduce

Any use of instanceof pattern with final keyword trigger the rule:


if (o instanceof final String k) {   // <--- here final keyword is not recognized
      return key.equals(k.getKey());
}

Expected behaviour
When using instanceof pattern with final keyword the rule must not be triggered.

Screenshots

Image

Software Versions

  • SonarQube Version: v25.8.0.112029
  • Plugin Version: 2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions