You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 27, 2021. It is now read-only.
I'm actually quite shocked no one else has reported this, given how often we run into it. SonarQube analysis of many of our TypeScript files usually produces one or two of these kinds of code smells:
'foo' is already declared in the upper scope.
The code smell is always incorrect because the variable is not declared anywhere else, nor does that identifier appear anywhere else. It's actually quite the mystery why this rule is getting triggered.
Rule key: It's not apparent where to get this. Provide some instructions in the template maybe?
Reproducer
Here's a sanitized snippet of one of the files triggering this rule incorrectly:
import { a, b, c } from 'package-one';
import { d } from './local-file';
interface I {
e: string;
f: string;
g: string;
}
function foo(arg: string): I {
if (!d.test(arg)) {
process.stdout.write('some error string');
process.exit(1);
}
const { h, g, i, j } = new URL(arg);
...
In this example, SonarQube incorrectly reports:
'g' is already declared in the upper scope.
Even though it's clear that g is not defined anywhere else.