SonarSource / SonarTS

Static code analyzer for TypeScript
GNU Lesser General Public License v3.0
761 stars 53 forks source link

S109: Magic number -1 #896

Open nicolasbreuni opened 4 years ago

nicolasbreuni commented 4 years ago

I want to report a bug.

SonarTS version: 2.1
Node.js version: 10
TypeScript version: 3.5.3

SonarQube version: 8.0
SonarLint version and used IDE: Intellij IDEA
TSLint version: 5.20.1

Rule key: S109

Reproducer

// minimal reproducer if relevant
private readonly _id: number = -1; // No magic number: -1

Expected behavior

In the rule description -1, 0 and 1 are excluded numbers. Thus this line should not be reported.

image