Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

the autofix of the rule sonarjs/no-inverted-boolean-check breaks original logic when double !! prefixed the expression #187

Closed
aprilandjan opened this issue Dec 22, 2020 · 0 comments · Fixed by #278
Assignees
Labels
bug Something isn't working
Milestone

Comments

@aprilandjan
Copy link

I want to report a bug.

Reproducer

// `sonarjs/no-inverted-boolean-check` will report it
!!(a < b)

after apply autofix of this rule, it will become:

!a >= b

When a = 0 and b = 2 for example, the original expression !!(0 < 2) will be true, but after autofix, the expression !0 <= 2 will be false, which will be an error.

I cloned this repo locally and add the case, and here is the result:

image

Expected behavior

eslint-plugin-sonarjs version:

current repo version

eslint version:

current repo version

Node.js version:

v12.13.0

Rule key:

sonarjs/no-inverted-boolean-check

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Something isn't working
Projects
None yet
3 participants