charlesdaniels / bitshuffle

BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

Add `pylint` to pre-commit checks #53

Closed jyn514 closed 6 years ago

jyn514 commented 6 years ago

Thoughts?

Pylint is a style-checker similar to but different from pycodestyle.

It can

and perform many, many other checks.

Since the linter is extremely strict, I suggest starting at a required code health of 7.0 and slowly increasing the required value as the project matures.

Sample output:

 % pylint bitshuffle.py
No config file found, using default configuration
************* Module bitshuffle.bitshuffle
W:414, 0: TODO: check editor when encoding as well as decoding (fixme)
C:184, 0: Wrong continued indentation (remove 5 spaces).
                             "the input file and write it to the output.")
                        |    ^ (bad-continuation)
C:211, 0: Wrong continued indentation (remove 5 spaces).
                             "Ignored if decoding packets. " +
                        |    ^ (bad-continuation)
C:212, 0: Wrong continued indentation (remove 5 spaces).
                             "Currently supported: 'bz2', 'gzip'.")
                        |    ^ (bad-continuation)
W:334, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:337, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:338, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:340, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:341, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:343, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:344, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:347, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:350, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:352, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:354, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:355, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:356, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:357, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:358, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:359, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:360, 0: Bad indentation. Found 20 spaces, expected 16 (bad-indentation)
W:362, 0: Bad indentation. Found 20 spaces, expected 16 (bad-indentation)
W:363, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:364, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:366, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:368, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:369, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:370, 0: Bad indentation. Found 20 spaces, expected 16 (bad-indentation)
W:371, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:372, 0: Bad indentation. Found 20 spaces, expected 16 (bad-indentation)
W:374, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:375, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:376, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:377, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
C:378, 0: Wrong continued indentation (remove 5 spaces).
                          % (index, packet[packet_hash]))
                     |    ^ (bad-continuation)
W:380, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:382, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:383, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:384, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:385, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:387, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:391, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:392, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:393, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:396, 0: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
W:397, 0: Bad indentation. Found 16 spaces, expected 12 (bad-indentation)
W:398, 0: Bad indentation. Found 8 spaces, expected 4 (bad-indentation)
W:338, 0: Anomalous backslash in string: '\('. String constant might be missing an r prefix. (anomalous-backslash-in-string)
W:338, 0: Anomalous backslash in string: '\('. String constant might be missing an r prefix. (anomalous-backslash-in-string)
W:338, 0: Anomalous backslash in string: '\)'. String constant might be missing an r prefix. (anomalous-backslash-in-string)
W:338, 0: Anomalous backslash in string: '\)'. String constant might be missing an r prefix. (anomalous-backslash-in-string)
W:463, 0: Redefining built-in 'hash' (redefined-builtin)
C:  1, 0: Missing module docstring (missing-docstring)
W: 25, 4: Wildcard import errors (wildcard-import)
W: 27, 4: Wildcard import errors (wildcard-import)
W: 35, 4: Statement seems to have no effect (pointless-statement)
W: 36, 4: Statement seems to have no effect (pointless-statement)
C: 39, 4: Missing function docstring (missing-docstring)
C: 41, 8: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
C: 42,71: Variable name "f" doesn't conform to snake_case naming style (invalid-name)
C: 46, 4: Missing function docstring (missing-docstring)
C: 47,56: Variable name "f" doesn't conform to snake_case naming style (invalid-name)
C: 55, 4: Constant name "file_type" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 57, 4: Class name "file_type" doesn't conform to PascalCase naming style (invalid-name)
C: 60, 0: Constant name "version" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 62, 0: Constant name "stderr" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 63, 0: Constant name "stdout" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 64, 0: Constant name "stdin" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 65, 0: Constant name "compress" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 66, 0: Constant name "debug" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 67, 0: Constant name "verbose" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 68, 0: Constant name "compatlevel" doesn't conform to UPPER_CASE naming style (invalid-name)
C: 71, 0: Constant name "default_msg" doesn't conform to UPPER_CASE naming style (invalid-name)
W: 75,55: Redefining name 'compress' from outer scope (line 65) (redefined-outer-name)
C:102, 8: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
C:103,11: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
W:109,40: Redefining name 'compress' from outer scope (line 65) (redefined-outer-name)
R:109, 0: Too many arguments (6/5) (too-many-arguments)
W:134,16: Redefining name 'compress' from outer scope (line 65) (redefined-outer-name)
C:146, 4: Variable name "e" doesn't conform to snake_case naming style (invalid-name)
C:153, 8: Variable name "c" doesn't conform to snake_case naming style (invalid-name)
W:146, 4: Unused variable 'e' (unused-variable)
W:248,12: Redefining name 'compress' from outer scope (line 65) (redefined-outer-name)
C:166, 0: Missing function docstring (missing-docstring)
C:255,12: Variable name "p" doesn't conform to snake_case naming style (invalid-name)
C:279,39: Variable name "tf" doesn't conform to snake_case naming style (invalid-name)
C:290, 8: Variable name "e" doesn't conform to snake_case naming style (invalid-name)
W:290, 8: Unused variable 'e' (unused-variable)
R:166, 0: Too many branches (18/12) (too-many-branches)
R:166, 0: Too many statements (71/50) (too-many-statements)
C:309, 0: Missing function docstring (missing-docstring)
C:318,38: Variable name "f" doesn't conform to snake_case naming style (invalid-name)
R:309, 0: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
C:333, 0: Missing function docstring (missing-docstring)
R:333, 0: Too many local variables (19/15) (too-many-locals)
C:343,11: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
R:348,39: Comparison to literal (literal-comparison)
W:382,11: Using possibly undefined loop variable 'packet' (undefined-loop-variable)
W:334, 8: Unused variable 'comment' (unused-variable)
W:334,17: Unused variable 'compatibility' (unused-variable)
W:334,32: Unused variable 'encoding' (unused-variable)
W:335,12: Unused variable 'seq_end' (unused-variable)
W:352, 8: Unused variable 'segments' (unused-variable)
R:333, 0: Too many branches (14/12) (too-many-branches)
R:420, 8: The if statement can be replaced with 'var = bool(test)' (simplifiable-if-statement)
C:437, 0: Missing function docstring (missing-docstring)
C:451, 8: Variable name "e" doesn't conform to snake_case naming style (invalid-name)
C:457, 8: Variable name "e" doesn't conform to snake_case naming style (invalid-name)
C:463, 0: Missing function docstring (missing-docstring)
C:467, 0: Missing function docstring (missing-docstring)
C:478, 0: Function name "exitWithError" doesn't conform to snake_case naming style (invalid-name)
C:478, 0: Missing function docstring (missing-docstring)
C:485, 0: Function name "exitSuccessfully" doesn't conform to snake_case naming style (invalid-name)
C:485, 0: Missing function docstring (missing-docstring)
C:491, 0: Missing function docstring (missing-docstring)

------------------------------------------------------------------
Your code has been rated at 5.91/10 (previous run: 5.02/10, +0.89)
charlesdaniels commented 6 years ago

Sounds good to me. My nit with this is that it looks like it's getting upset at indents to make lists/dicts look readable. Skimming the output, it looks like it does not like this style:

x = {'foo': 'bar',
     'baz': 'quux'}

I may be misreading the output of pylint though. In any case, I think it's a good idea, we may just need to tweak which errors/warnings get ignored.

jyn514 commented 6 years ago

Closed in https://github.com/charlesdaniels/bitshuffle/pull/56