shinken-solutions / shinken

Flexible and scalable monitoring framework
http://www.shinken-monitoring.org
GNU Affero General Public License v3.0
1.13k stars 335 forks source link

Coding style with pylint #1393

Open Seb-Solon opened 10 years ago

Seb-Solon commented 10 years ago

Hi!

We recently agreed that a coding style was necessary to ensure better code quality and better contributing. I've started from a simple pylinrc file and did the following modifications :

@@ -44,7 +44,7 @@
 # --enable=similarities". If you want to run only the classes checker, but have
 # no Warning level messages displayed, use"--disable=all --enable=classes
 # --disable=W"
-#disable=
+disable=W0142

 [REPORTS]

@@ -76,6 +76,9 @@
 # Template used to display messages. This is a python new-style format string
 # used to format the message information. See doc for all details
 #msg-template=
+# parsable
+msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
+

 [BASIC]
@@ -238,7 +241,7 @@
 [FORMAT]

 # Maximum number of characters on a single line.
-max-line-length=80
+max-line-length=100

 # Regexp for a line that is allowed to be longer than the limit.
 ignore-long-lines=^\s*(# )?<?https?://\S+>?$

The line to discuss is the disable one.

For now I encountered the following errors :

W1401 anomalous-backslash-in-string
W1201 logging-not-lazy
W0703 broad-except
W0631 undefined-loop-variable
W0623 redefine-in-handler
W0622 redefined-builtin
W0621 redefined-outer-name
W0614 unused-wildcard-import
W0613 unused-argument
W0612 unused-variable
W0611 unused-import
W0603 global-statement
W0602 global-variable-not-assigned
W0511 fixme
W0403 relative-import
W0401 wildcard-import
W0311 bad-indentation
W0231 super-init-not-called
W0221 arguments-differ
W0212 protected-access
W0201 attribute-defined-outside-init
W0142 star-args
W0141 bad-builtin
W0122 exec-used
W0121 old-raise-syntax
W0110 (deprecated-lambda) 
W0109 duplicate-key 
W0107 unnecessary-pass
W0106 expression-not-assigned
W0105 pointless-string-statement
W0102 dangerous-default-value
W0101 unreachable

R0923 interface-not-implemented
R0921 abstract-class-not-used
R0915 too-many-statements
R0914 too-many-locals
R0913 too-many-arguments
R0912 too-many-branches
R0911 too-many-return-statements
R0904 too-many-public-methods
R0903 too-few-public-methods
R0902 too-many-instance-attributes
R0901 too-many-ancestors
R0801 duplicate-code
R0201 no-self-use

F0401 import-error

E1103 maybe-no-member
E1101 no-member)
E1003 bad-super-call)
E1001 slots-on-old-class
E0602 undefined-variable
E0213 no-self-argument
E0211 no-method-argument
E0203 access-member-before-definition
E0102 function-redefined

C1001 old-style-class
C0326 bad-whitespace
C0325 superfluous-parens
C0321 multiple-statements
C0303 trailing-whitespace
C0301 line-too-long
C0111 missing-docstring
C0103 invalid-name

Fow now the only one disabled is W0142. To get a description of the error type the following :

pylint --help-msg=W0142
:star-args (W0142): *Used * or ** magic*
  Used when a function or method is called using `*args` or `**kwargs` to
  dispatch arguments. This doesn't improve readability and should be used with
  care. This message belongs to the basic checker.

Feel free to give your opinion on what we should skip or not. Fow now there is only 1 skip.

titilambert commented 10 years ago

+1 :)

t0xicCode commented 10 years ago

:+1:

vaxvms commented 9 years ago

There is already a pylint.rc in https://github.com/naparuba/shinken/blob/master/test/jenkins/pylint.rc