From d47d04bfec9cbd8e83287cf21b1154457c73b847 Mon Sep 17 00:00:00 2001 From: Benediktas Prekeris Date: Tue, 14 Feb 2017 14:24:42 +0200 Subject: [PATCH 01/13] #507 added line too long page --- Pylint-line-too-long.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Pylint-line-too-long.md b/Pylint-line-too-long.md index a8839025..841942e8 100644 --- a/Pylint-line-too-long.md +++ b/Pylint-line-too-long.md @@ -3,8 +3,20 @@ Pattern: Line too long Issue: - ## Description +Your source code should not contain lines that are longer than 80 characters long. If you have a line that is longer than 80 character, break it up into multiple lines. Use the '\' character at the end of a line to tell the Python interpreter that the statment continues on the next line: Here is an example of how to break up a long boolean expression into three lines: +```python + if ( ((blah < 0 ) and (grr > 234)) \ + or ((foo == 3456) and (grr <= 4444)) \ + or ((blah > 10) and (grr == 3333)) \ + ): + print "this crazy condition is true" + print "and my code is really easy to read because" + print "I didn't wrap lines!" -Used when a line is longer than a given number of characters. + else: + print "this crazy condition is false" +``` +The easiest way to make sure you are not adding lines longer than 80 characters wide is to always work inside a window that is exactly 80 characters wide. If your line starts wrapping around to the next line, its too long. ## Further Reading From 03930cd81d92dc5f4ca6f3f71360b7ad3a334fc5 Mon Sep 17 00:00:00 2001 From: Benediktas Prekeris Date: Tue, 14 Feb 2017 14:45:00 +0200 Subject: [PATCH 02/13] #507 edited line too long --- Pylint-line-too-long.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Pylint-line-too-long.md b/Pylint-line-too-long.md index 841942e8..56d4c1ae 100644 --- a/Pylint-line-too-long.md +++ b/Pylint-line-too-long.md @@ -16,7 +16,6 @@ Your source code should not contain lines that are longer than 80 characters lon else: print "this crazy condition is false" ``` -The easiest way to make sure you are not adding lines longer than 80 characters wide is to always work inside a window that is exactly 80 characters wide. If your line starts wrapping around to the next line, its too long. ## Further Reading From 612bf3e656c522f3ab04c18a5fd774ee835776ea Mon Sep 17 00:00:00 2001 From: Benediktas Prekeris Date: Tue, 14 Feb 2017 15:21:25 +0200 Subject: [PATCH 03/13] #507 refactored unused variable rule --- Pylint-unused-variable.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Pylint-unused-variable.md b/Pylint-unused-variable.md index 2c52efbc..a0626a6c 100644 --- a/Pylint-unused-variable.md +++ b/Pylint-unused-variable.md @@ -4,4 +4,12 @@ Issue: - ## Description -Used when a variable is defined but not used. \ No newline at end of file +Unused local variables and unnecessary assigments increase code lines and decrease source code understanding. + +```python +firstNumber = 100 +secondNumber = 200 + +print secondNumber +print "firstNumber variable needs to be removed, because it's never used in the script" +``` \ No newline at end of file From 22b746320e275f89690cd257ec41fcae1dfa8c1a Mon Sep 17 00:00:00 2001 From: BenasP Date: Wed, 15 Feb 2017 16:18:28 +0200 Subject: [PATCH 04/13] Updated Pylint-line-too-long rule --- Pylint-line-too-long.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Pylint-line-too-long.md b/Pylint-line-too-long.md index 56d4c1ae..fa3eb893 100644 --- a/Pylint-line-too-long.md +++ b/Pylint-line-too-long.md @@ -3,7 +3,7 @@ Pattern: Line too long Issue: - ## Description -Your source code should not contain lines that are longer than 80 characters long. If you have a line that is longer than 80 character, break it up into multiple lines. Use the '\' character at the end of a line to tell the Python interpreter that the statment continues on the next line: Here is an example of how to break up a long boolean expression into three lines: +Your source code should not contain lines that are longer than `max-line-length` characters long. If you have a line that is longer than `max-line-length` characters long, break it up into multiple lines. Use the `\` character at the end of a line to tell the Python interpreter that the statement continues on the next line. Here is an example of how to break up a long boolean expression into three lines. ```python if ( ((blah < 0 ) and (grr > 234)) \ or ((foo == 3456) and (grr <= 4444)) \ @@ -16,7 +16,9 @@ Your source code should not contain lines that are longer than 80 characters lon else: print "this crazy condition is false" ``` +By default `max-line-length` is 80 characters per line, but we are very liberal so we made it 150 characters per line just for you. ## Further Reading +* [Pylint - C0301](http://pylint-messages.wikidot.com/messages:c0301) -* [Pylint - C0301](http://pylint-messages.wikidot.com/messages:c0301) \ No newline at end of file +Have your own Pylint rules? No problem, simply add .pylintrc file to the root of this branch. From b9b3958ecfe665c76735ceb0ec47739f97be221c Mon Sep 17 00:00:00 2001 From: BenasP Date: Fri, 17 Feb 2017 09:48:09 +0200 Subject: [PATCH 05/13] Removed Have your own Pylint rules --- Pylint-line-too-long.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/Pylint-line-too-long.md b/Pylint-line-too-long.md index fa3eb893..30ebd4a9 100644 --- a/Pylint-line-too-long.md +++ b/Pylint-line-too-long.md @@ -20,5 +20,3 @@ By default `max-line-length` is 80 characters per line, but we are very liberal ## Further Reading * [Pylint - C0301](http://pylint-messages.wikidot.com/messages:c0301) - -Have your own Pylint rules? No problem, simply add .pylintrc file to the root of this branch. From d835bbd5927bbd624da7c2b0d6b0a8cc46f816c7 Mon Sep 17 00:00:00 2001 From: BenasP Date: Tue, 21 Feb 2017 09:21:14 +0200 Subject: [PATCH 06/13] Updated unused variable rule --- Pylint-unused-variable.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Pylint-unused-variable.md b/Pylint-unused-variable.md index a0626a6c..b6e81d1d 100644 --- a/Pylint-unused-variable.md +++ b/Pylint-unused-variable.md @@ -4,12 +4,18 @@ Issue: - ## Description -Unused local variables and unnecessary assigments increase code lines and decrease source code understanding. +Unused local variables and unnecessary assignments increase code lines and decrease understanding of source code. In some cases unused variables is the result of unimplemented functionality that developer forgets to do, in that case ticket should be created to remind what to do later. +Example of incorrect code: ```python -firstNumber = 100 -secondNumber = 200 +number = 100 -print secondNumber -print "firstNumber variable needs to be removed, because it's never used in the script" -``` \ No newline at end of file +print "Program contains unused variable" +``` + +Example of correct code: +```python +number = 100 + +print number; +``` From 1954d758ac33fee457c1496879a6f7aed22a1bef Mon Sep 17 00:00:00 2001 From: BenasP Date: Thu, 23 Feb 2017 16:47:57 +0200 Subject: [PATCH 07/13] Update Pylint-unused-variable.md --- Pylint-unused-variable.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pylint-unused-variable.md b/Pylint-unused-variable.md index b6e81d1d..575323b2 100644 --- a/Pylint-unused-variable.md +++ b/Pylint-unused-variable.md @@ -4,7 +4,7 @@ Issue: - ## Description -Unused local variables and unnecessary assignments increase code lines and decrease understanding of source code. In some cases unused variables is the result of unimplemented functionality that developer forgets to do, in that case ticket should be created to remind what to do later. +Unused local variables increase code lines and decrease understanding of source code. In some cases unused variables is the result of unimplemented functionality that developer forgets to do, in that case ticket should be created to remind what to do later. Example of incorrect code: ```python From 7f231188866f750d49efd76610355d883b0fb536 Mon Sep 17 00:00:00 2001 From: BenasP Date: Thu, 23 Feb 2017 17:04:33 +0200 Subject: [PATCH 08/13] Update Pylint-line-too-long.md --- Pylint-line-too-long.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Pylint-line-too-long.md b/Pylint-line-too-long.md index 30ebd4a9..4612d1d6 100644 --- a/Pylint-line-too-long.md +++ b/Pylint-line-too-long.md @@ -16,7 +16,8 @@ Your source code should not contain lines that are longer than `max-line-length` else: print "this crazy condition is false" ``` -By default `max-line-length` is 80 characters per line, but we are very liberal so we made it 150 characters per line just for you. +By default PEP 8 recommends 79 - 99 characters per line, but we are very liberal so we made it 159 characters per line just for you. +You can set `max-line-length` in Pylint configuration file depending on your needs. ## Further Reading * [Pylint - C0301](http://pylint-messages.wikidot.com/messages:c0301) From c11a4e1c7df2993620828bb9c95d1e04badff036 Mon Sep 17 00:00:00 2001 From: BenasP Date: Mon, 27 Feb 2017 10:09:54 +0200 Subject: [PATCH 09/13] Update Pylint-line-too-long.md --- Pylint-line-too-long.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pylint-line-too-long.md b/Pylint-line-too-long.md index 4612d1d6..a5b62bb5 100644 --- a/Pylint-line-too-long.md +++ b/Pylint-line-too-long.md @@ -3,7 +3,7 @@ Pattern: Line too long Issue: - ## Description -Your source code should not contain lines that are longer than `max-line-length` characters long. If you have a line that is longer than `max-line-length` characters long, break it up into multiple lines. Use the `\` character at the end of a line to tell the Python interpreter that the statement continues on the next line. Here is an example of how to break up a long boolean expression into three lines. +Your source code should not contain very long lines. If you have lines that are very long you should break it up into multiple lines, because when code is not clearly visible it's very difficult to understand what it does. Use the `\` character at the end of a line to tell the Python interpreter that the statement continues on the next line. Here is an example of how to break up a long boolean expression into three lines. ```python if ( ((blah < 0 ) and (grr > 234)) \ or ((foo == 3456) and (grr <= 4444)) \ From c2ad8bc3468b625b7fc5acb1e0429d1ded04dbe8 Mon Sep 17 00:00:00 2001 From: BenasP Date: Mon, 27 Feb 2017 10:21:11 +0200 Subject: [PATCH 10/13] Update Pylint-unused-variable.md --- Pylint-unused-variable.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pylint-unused-variable.md b/Pylint-unused-variable.md index 575323b2..b2cefef8 100644 --- a/Pylint-unused-variable.md +++ b/Pylint-unused-variable.md @@ -4,7 +4,7 @@ Issue: - ## Description -Unused local variables increase code lines and decrease understanding of source code. In some cases unused variables is the result of unimplemented functionality that developer forgets to do, in that case ticket should be created to remind what to do later. +Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. Example of incorrect code: ```python From e57243a14dbc6bb02001d0b57cfa02eecc60c0b8 Mon Sep 17 00:00:00 2001 From: BenasP Date: Tue, 28 Feb 2017 16:25:17 +0200 Subject: [PATCH 11/13] Update Pylint-unused-variable.md --- Pylint-unused-variable.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pylint-unused-variable.md b/Pylint-unused-variable.md index b2cefef8..023cc3e1 100644 --- a/Pylint-unused-variable.md +++ b/Pylint-unused-variable.md @@ -6,14 +6,14 @@ Issue: - Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. -Example of incorrect code: +Example of **incorrect** code: ```python number = 100 print "Program contains unused variable" ``` -Example of correct code: +Example of **correct** code: ```python number = 100 From e730de8c4abf5e4ddea8e660c2bf9a1f1cc2217c Mon Sep 17 00:00:00 2001 From: Kestas Date: Wed, 1 Mar 2017 07:42:20 -0800 Subject: [PATCH 12/13] Update Pylint-unused-variable.md --- Pylint-unused-variable.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pylint-unused-variable.md b/Pylint-unused-variable.md index 023cc3e1..0c753c55 100644 --- a/Pylint-unused-variable.md +++ b/Pylint-unused-variable.md @@ -4,7 +4,7 @@ Issue: - ## Description -Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers. +Variables that are declared and not used anywhere in the code are most likely an error resulting from incomplete refactoring. Such variables take up space in the code and can lead to confusion and complexity. Example of **incorrect** code: ```python From ab695b1fdb2022c4f5c22d40e3b18444321cfb6a Mon Sep 17 00:00:00 2001 From: Kestas Date: Wed, 1 Mar 2017 07:56:06 -0800 Subject: [PATCH 13/13] Update Pylint-line-too-long.md --- Pylint-line-too-long.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pylint-line-too-long.md b/Pylint-line-too-long.md index a5b62bb5..47920657 100644 --- a/Pylint-line-too-long.md +++ b/Pylint-line-too-long.md @@ -3,7 +3,7 @@ Pattern: Line too long Issue: - ## Description -Your source code should not contain very long lines. If you have lines that are very long you should break it up into multiple lines, because when code is not clearly visible it's very difficult to understand what it does. Use the `\` character at the end of a line to tell the Python interpreter that the statement continues on the next line. Here is an example of how to break up a long boolean expression into three lines. +Your source code should not contain very long lines. If you have very long lines you should break it up into multiple lines. When code is not easily visible it's difficult to understand what it does. Use the `\` character at the end of a line to tell the Python interpreter that the statement continues on the next line. Here is an example of how to break up a long boolean expression into three lines. ```python if ( ((blah < 0 ) and (grr > 234)) \ or ((foo == 3456) and (grr <= 4444)) \