Skip to content

Commit d8ce625

Browse files
author
Aurore Dupuis
committed
Initial version working with Pylint 1.5
1 parent c6a8ea4 commit d8ce625

34 files changed

+2006
-0
lines changed

COPYING

Lines changed: 340 additions & 0 deletions
Large diffs are not rendered by default.

checkers/__init__.py

Whitespace-only changes.

checkers/cnes_checker.py

Lines changed: 690 additions & 0 deletions
Large diffs are not rendered by default.

pylintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[MASTER]
2+
3+
# List of plugins (as comma separated values of python modules names) to load,
4+
# usually to register additional checkers.
5+
load-plugins=cnes_checker,pylint.extensions.check_elif
6+
7+
[DESIGN]
8+
9+
# Maximum number of return / yield for function / method body
10+
max-returns=1
11+
12+
# Maximum number of statements in function / method body
13+
max-statements=100
14+
15+
# force the detection of all the missing parameters (docstrings with a mere
16+
# description won't be tolerated)
17+
accept-no-param-doc=n

test/functional/__init__.py

Whitespace-only changes.

test/functional/__main__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Checks the use of sys.exit() out of the module scope triggers a refactor
2+
message
3+
"""
4+
#pylint: disable=too-few-comments,missing-docstring-field
5+
6+
import sys as s
7+
import sys
8+
from sys import exit as e
9+
10+
def main():
11+
"""Calling sys.exit() from here is not a good practice"""
12+
if True:
13+
e(4) # [sys-exit-used]
14+
else:
15+
s.exit(5) # [sys-exit-used]
16+
17+
e(6)
18+
toto.exit(10)
19+
exit(11)
20+
21+
if True:
22+
sys.exit(7)
23+
24+
if __name__ == '__main__':
25+
main()
26+
sys.exit(1)

test/functional/__main__.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sys-exit-used:13:main:Consider dropping use of sys.exit()
2+
sys-exit-used:15:main:Consider dropping use of sys.exit()

test/functional/bad_exit_condition.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Checks that loop exit conditions don't use equality or difference comparison
2+
"""
3+
#pylint: disable=too-few-comments,missing-docstring-field
4+
string = ' hello world'
5+
i = 0
6+
while string[i] == ' ': # [bad-exit-condition]
7+
i += 1
8+
i = 0
9+
while string[i] != 'h': # [bad-exit-condition]
10+
i += 1
11+
while i < 5 and string[i] == ' ': # [bad-exit-condition]
12+
i += 1
13+
while i > 0:
14+
i -= 1
15+
while True:
16+
pass
17+
while string[i] == ' ' and True or i != 3: # [bad-exit-condition]
18+
pass
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bad-exit-condition:6::Exit condition based on equality or difference
2+
bad-exit-condition:9::Exit condition based on equality or difference
3+
bad-exit-condition:11::Exit condition based on equality or difference
4+
bad-exit-condition:17::Exit condition based on equality or difference

test/functional/builtin_name_used.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Check no method nor attribute it named after a builtin"""
2+
#pylint: disable=too-few-comments,missing-docstring-field
3+
4+
class MyClass(object):
5+
def __init__(self):
6+
((self.file, (self.str, self.something)), plop) = (('test.txt', 'hello'), 'plop') # [builtin-name-used, builtin-name-used]
7+
8+
bool = True # [builtin-name-used]
9+
10+
def map(self): # [builtin-name-used]
11+
pass
12+
13+
def dummy_method(cls):
14+
pass
15+
zip = classmethod(dummy_method) # [builtin-name-used]
16+
17+
MyClass.dict = "hi there" # [builtin-name-used]
18+
19+
20+
class ChildClass(MyClass):
21+
22+
def map(self):
23+
"""inherited: should be ok"""

0 commit comments

Comments
 (0)