Skip to content

Instantly share code, notes, and snippets.

@jasonamyers
Last active November 29, 2015 16:09
Show Gist options
  • Select an option

  • Save jasonamyers/2edc63133a1dc4f22892 to your computer and use it in GitHub Desktop.

Select an option

Save jasonamyers/2edc63133a1dc4f22892 to your computer and use it in GitHub Desktop.
A proposed list of Python rules

Critical

Issue Default
Methods and field names should not differ only by capitalization n/a
Conditions in related "if/elif/else if" statements should not have the same condition n/a
"return" and "yield" cannot be used in the same function n/a
"exit" should accept type, value, and traceback arguments n/a
"init" should not return a value n/a

Major

Issue Default
Source files should not have any duplicated blocks n/a
Failed unit tests should be fixed n/a
Skipped unit tests should be either removed or fixed n/a
Lines should have sufficient coverage by unit tests Coverage: 80%
Branches should have sufficient coverage by unit tests Coverage: 80%
Source files should have a sufficient density of comment lines 25%
Backticks should not be used n/a
Files should not be too complex McCabe: 150
Classes should not be too complex McCabe: 100
Functions should not be too complex McCabe: 10
"<>" should not be used to test inequality n/a
Parser failure n/a
The "exec" statement should not be used n/a
Pre-increment and pre-decrement should not be used n/a
The "print" statement should not be used n/a
Files should not have too many lines Lines: 1000
Collapsible "if" statements should be merged n/a
Functions, methods and lambdas should not have too many parameters Parameters: 10
Nested blocks of code should not be left empty n/a
Useless parentheses around expressions should be removed to prevent any misunderstanding n/a
"FIXME" tags should be handled n/a
Functions should not contain too many return statements Returns: 3
Sections of code should not be "commented out" n/a
IP addresses should not be hardcoded n/a
Control flow statements "if", "for", "while", "try" and "with" should not be nested too deeply Nest Levels: 4
Class names should comply with a naming convention ^[A-Z_][a-zA-Z0-9]+$
Method names should comply with a naming convention ^[a-z_][a-z0-9_]{2,30}$
Function names should comply with a naming convention ^[a-z_][a-z0-9_]{2,30}$
Field names should comply with a naming convention ^[_a-z][_a-z0-9]*$
Local variable and function parameter names should comply with a naming convention ^[a-z][a-z0-9]*$
Module names should comply with a naming convention (([a-z_][a-z0-9_]*)
A field should not duplicate the name of its containing class n/a
"break" and "continue" should not be used outside a loop n/a
"" should only be used as an escape character outside of raw strings n/a
Docstrings should be defined Every module, function, class, or method
Parentheses should not be used after certain keywords assert, del, elif, except, for, if, in, not, raise, return, while, and yield
New-style classes should be used n/a
Jump statements should not be followed by other statements Jumps: return, break, continue, and raise
Two branches in the same conditional structure should not have exactly the same implementation n/a
Methods that don't access instance data should be "static" n/a
"yield" and "return" should not be used outside functions n/a
"pass" should not be used needlessly n/a
No use of if/else on single line outside of comprehension n/a

Minor

Issue Default
Lines should not be too long Characters: 79
Long suffix "L" should be upper case n/a
Statements should be on separate lines No use of ;
Files should contain an empty new line at the end n/a
Lines should not end with trailing whitespaces n/a
TODO and FIXME comments should contain a reference to a person [ ]*([ _a-zA-Z0-9@.]+)
Comments should not be located at the end of lines of code n/a
@jasonamyers
Copy link
Copy Markdown
Author

The next step is to define each rule in non @jasonamyers terms and create time to fix tech debt numbers for each issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment