Skip to content

Commit 9409348

Browse files
committed
Add using-constant-test (W0125)
1 parent 767f2c2 commit 9409348

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Emitted when a conditional statement (If or ternary if) uses a constant value for its test. This might not be what the user intended to do.
2+
3+
A simple example that will be reported:
4+
5+
if True: pass

src/main/resources/docs/description/description.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,5 +834,11 @@
834834
"title": "Prohibit inheriting non classes",
835835
"description": "Do not inherit from something which is not a class.",
836836
"timeToFix": 5
837+
},
838+
{
839+
"patternId": "W0125",
840+
"title": "Prohibit a conditional statement with a constant value",
841+
"description": "Prohibits when a conditional statement (If or ternary if) uses a constant value for its test.",
842+
"timeToFix": 5
837843
}
838844
]

src/main/resources/docs/patterns.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,11 @@
706706
"patternId": "W1501",
707707
"level": "Warning",
708708
"category": "ErrorProne"
709+
},
710+
{
711+
"patternId": "W0125",
712+
"level": "Warning",
713+
"category": "ErrorProne"
709714
}
710715
]
711716
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##Patterns: W0125
2+
3+
print('ola')
4+
5+
this_is_an_intentionally_long_name_to_trigger_a_line_too_long_message_from_pylint = None
6+
7+
##Warn: W0125
8+
if True: pass
9+
10+
while True:
11+
break
12+
13+
while True:
14+
break # 4 space indent

0 commit comments

Comments
 (0)