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

Labels

🗃️ rulerule improvment or rule development or bug💉 bugSomething isn't working

Type

No fields configured for Bug.

Projects

Status
Ready To Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions