Skip to content

Commit 7893fd2

Browse files
Add documentation for 'too-many-lines' (#8323)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
1 parent d025472 commit 7893fd2

File tree

7 files changed

+39
-2
lines changed

7 files changed

+39
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def is_palindrome(string): # [too-many-lines]
2+
left_pos = 0
3+
right_pos = len(string) - 1
4+
while right_pos >= left_pos:
5+
if not string[left_pos] == string[right_pos]:
6+
return False
7+
left_pos += 1
8+
right_pos -= 1
9+
return True
10+
11+
12+
def main():
13+
print(isPalindrome("aza"))
14+
print(isPalindrome("racecar"))
15+
print(isPalindrome("trigger"))
16+
print(isPalindrome("ogre"))
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
You can help us make the doc better `by contributing <https://github.com/PyCQA/pylint/issues/5953>`_ !
1+
When a module has too many lines it can make it difficult to read and understand. There might be
2+
performance issue while editing the file because the IDE must parse more code. You need more expertise
3+
to navigate the file properly (go to a particular line when debugging, or search for a specific code construct, instead of navigating by clicking and scrolling)
4+
5+
This measure is a proxy for higher cyclomatic complexity that you might not be calculating if you're not using ``load-plugins=pylint.extensions.mccabe,``. Cyclomatic complexity is slower to compute, but also a more fine grained measure than raw SLOC. In particular, you can't make the code less readable by making a very complex one liner if you're using cyclomatic complexity.
6+
7+
The example simplify the code, but it's not always possible. Most of the time bursting the file
8+
by creating a package with the same API is the only solution. Anticipating and creating the file
9+
from the get go will permit to have the same end result with a better version control history.

doc/data/messages/t/too-many-lines/good.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__all__ = ["is_palindrome", "main"]
2+
3+
from is_palindrome import is_palindrome
4+
from main import main
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def is_palindrome(string):
2+
return string == string[::-1]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from is_palindrome import is_palindrome
2+
3+
4+
def main():
5+
for string in ["aza", "racecar", "trigger", "ogre"]:
6+
print(is_palindrome(string))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[main]
2+
max-module-lines=15

0 commit comments

Comments
 (0)