Sonar complaining about duplication where I don't see any duplication

  • Enterprise Edition
  • Version 7.9.1 (build 27448)

“Major Code Smell” On someText (SonarAnalyzer (TypeScript))

Update or refactor this function so that its implementation doesn’t duplicate the one on line [line for someOtherText()].

TypeScript:

class SomeClass
  someBoolean: boolean; 
  get someText() {
    return this.someBoolean
      ? 'Unique text 1'
      : 'Unique text 2';
  }
  get someOtherText() {
    return this.someBoolean
      ? 'Unique text 3'
      : 'Unique text 4';
  }
}
1 Like

Hi,

Welcome to the community!

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

7.9.1 → 8.9.9 → 9.6 (last step optional)

You may find the Upgrade Guide and the LTS-to-LTS Upgrade Notes helpful. If you have questions about upgrading, feel free to open a new thread for that here.

If your issue persists after upgrade, please come back to us.

Ok, will wait for organization to upgrade to new Sonar version.