steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
154 stars 99 forks source link

codebase does not pass linting, and it should, so that passing linting can be part of the test suite #130

Open sneak opened 6 years ago

sneak commented 6 years ago

The codebase conforms to pep8 formatting now (after I fixed it) but it still doesn't pass flake8 linting checks.

see current list of failures here:

https://circleci.com/gh/steemit/steem-python/30

We should fix this and merge in the add-linting-support-to-tests branch to ensure that no sloppy or error-prone code makes it onto master. This should aid in code review, much like -Werror does in steemd.

branch: https://github.com/steemit/steem-python/tree/add-linting-support-to-tests

a short excerpt:

_______________________ [pylint] steembase/operations.py _______________________
R: 51, 4: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
W:104,12: Unused variable 'name' (unused-variable)
C:142,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:178,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:196,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:212,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
R:216,20: Consider merging these isinstance calls to isinstance(kwargs['json_metadata'], (dict, list)) (consider-merging-isinstance)
C:260,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:275,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:293,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:347,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:378,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:411,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:447,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:465,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:480,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:494,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:512,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:532,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:546,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:562,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:577,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:595,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:609,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:625,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:640,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:654,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:678,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:693,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
R:696,20: Consider merging these isinstance calls to isinstance(kwargs['json'], (dict, list)) (consider-merging-isinstance)
C:723,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
C:729,33: Using type() instead of isinstance() for a typecheck. (unidiomatic-typecheck)
_________________________________ FLAKE8-check _________________________________
/build/steembase/storage.py:239:17: W503 line break before binary operator
/build/steembase/storage.py:395:17: W503 line break before binary operator

________________________ [pylint] steembase/storage.py _________________________
W: 68,17: Use % formatting in logging functions and pass the % parameters as arguments (logging-format-interpolation)
W: 82,29: Use % formatting in logging functions and pass the % parameters as arguments (logging-format-interpolation)
W: 95, 4: Useless super delegation in method '__init__' (useless-super-delegation)
R:147, 8: Unnecessary "else" after "return" (no-else-return)
W:208, 4: Useless super delegation in method '__init__' (useless-super-delegation)
W:247, 8: No exception type(s) specified (bare-except)
R:270, 8: Unnecessary "else" after "return" (no-else-return)
R:273,12: Unnecessary "else" after "return" (no-else-return)
R:281, 8: Unnecessary "else" after "return" (no-else-return)
R:287, 8: The if statement can be replaced with 'return bool(test)' (simplifiable-if-statement)
R:287, 8: Unnecessary "else" after "return" (no-else-return)
R:399, 4: Method could be a function (no-self-use)
_________________________________ FLAKE8-check _________________________________
/build/steembase/transactions.py:97:25: W503 line break before binary operator
/build/steembase/transactions.py:240:17: W503 line break before binary operator
/build/steembase/transactions.py:241:17: W503 line break before binary operator
/build/steembase/transactions.py:242:17: W503 line break before binary operator

______________________ [pylint] steembase/transactions.py ______________________
C:107, 0: Unnecessary parens after 'assert' keyword (superfluous-parens)
C:240, 0: Unnecessary parens after 'not' keyword (superfluous-parens)
C:242, 0: Unnecessary parens after 'not' keyword (superfluous-parens)
W: 30, 0: No exception type(s) specified (bare-except)
E: 26, 4: Unable to import 'secp256k1' (import-error)
C: 51,34: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition)
R:101, 4: Method could be a function (no-self-use)
R:112, 4: Method could be a function (no-self-use)
R:119, 4: Too many local variables (18/15) (too-many-locals)
R:119, 4: Method could be a function (no-self-use)
R:155, 4: Method could be a function (no-self-use)
W:189, 4: Dangerous default value [] as argument (dangerous-default-value)
R:189, 4: Too many local variables (19/15) (too-many-locals)
R:238, 4: Method could be a function (no-self-use)
R:245, 4: Too many local variables (22/15) (too-many-locals)
W:258, 8: Expression "[self.privkeys.append(item) for item in wifkeys if item not in self.privkeys]" is assigned to nothing (expression-not-assigned)
W:291,24: Specify string format arguments as logging function parameters (logging-not-lazy)
R:320,23: Comparison to literal (literal-comparison)
R:320,38: Comparison to literal (literal-comparison)
W:257, 8: Attribute 'privkeys' defined outside __init__ (attribute-defined-outside-init)
W:174, 8: Attribute 'chainid' defined outside __init__ (attribute-defined-outside-init)
W:184, 8: Attribute 'digest' defined outside __init__ (attribute-defined-outside-init)
W:183, 8: Attribute 'message' defined outside __init__ (attribute-defined-outside-init)
_________________________ [pylint] steembase/types.py __________________________
C: 51, 0: Unnecessary parens after 'not' keyword (superfluous-parens)
W: 68, 4: No exception type(s) specified (bare-except)
W:264, 4: Useless super delegation in method '__init__' (useless-super-delegation)
W:272, 4: Useless super delegation in method '__init__' (useless-super-delegation)
R:292, 8: Unnecessary "else" after "return" (no-else-return)
W:369,19: Redefining built-in 'type' (redefined-builtin)
W:369,25: Redefining built-in 'id' (redefined-builtin)
==================== 41 failed, 109 passed in 78.67 seconds ====================