Skip to content

Commit 6509220

Browse files
SONARPY-282 Update description for Rule S1940 (#1095)
1 parent 8ebb1fc commit 6509220

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<p>It is needlessly complex to invert the result of a boolean comparison. The opposite comparison should be made instead.</p>
22
<h2>Noncompliant Code Example</h2>
33
<pre>
4-
if (not(a == 2)): # Noncompliant
5-
b = not(i &lt; 10) # Noncompliant
6-
c = not(a is not b) NonCommpliant
7-
4+
if not a == 2: # Noncompliant
5+
b = not i &lt; 10 # Noncompliant
86
</pre>
97
<h2>Compliant Solution</h2>
108
<pre>
11-
if (a != 2):
12-
b = (i &gt;= 10)
9+
if a != 2 :
10+
b = i &gt;= 10
1311
</pre>
1412

python-checks/src/main/resources/org/sonar/l10n/py/rules/python/Sonar_way_profile.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"S1854",
4242
"S1862",
4343
"S1871",
44+
"S1940",
4445
"S2053",
4546
"S2068",
4647
"S2077",

0 commit comments

Comments
 (0)