All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.py.rules.python.S2761.html Maven / Gradle / Ivy

The newest version!

Why is this an issue?

The repetition of a prefix operator (not or ~) is usually a typo. The second operator invalidates the first one:

a = False
b = ~~a # Noncompliant: equivalent to "a"

While calling not twice is equivalent to calling the bool() built-in function, the latter increases the code readability, so it should be preferred.

a = 0

b = not not a # Noncompliant: use bool()

Exceptions

The rule does not raise an issue if the ~ function is overloaded in a customized class, as it is assumed to be the expected usage.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy