From 8afba2d82639c6d2b863fe82fe9f9e6b062df551 Mon Sep 17 00:00:00 2001 From: rachmadani haryono Date: Sat, 12 Aug 2017 19:26:59 +0800 Subject: [PATCH] Feature/pylint (#185) * fix: dev: os function name * new: test: pylint config * new: test: pylint test * chg: dev: linting guide * new: dev: add alternative commented test run command * chg: dev: max line length on PR template --- .github/PULL_REQUEST_TEMPLATE.md | 4 +-- .pylintrc | 47 ++++++++++++++++++++++++++++++++ .travis.yml | 1 + buku.py | 2 +- setup.py | 2 +- tox.ini | 2 ++ 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 .pylintrc diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d3804cd..56ba5b8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -27,11 +27,11 @@ This is more important than your design or code! Users check this first. #### Coding guidelines - Add new program options to a reasonable group. - *Single quote, single quote, single all the way!* -- A single line should be less than 80 chars in length. +- A single line should be less than 140 chars in length. - No trailing whitespaces. - Avoid append(), extend() and use concatenation if possible. - Use string concatenation than substitution if possible, except (logger) prints. -- Run `python3 -m flake8 buku.py`. +- We have automated linting test but you can also test it by running `python3 -m flake8 buku.py` and `python3 -m pylint buku.py`. - Add new API documentation, reasonable code comments. - If possible, add test cases for your new API under `tests/`. We are Travis integrated. - If possible, squash everything to a single commit. diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..fa56824 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,47 @@ +[MESSAGES CONTROL] +disable= + anomalous-backslash-in-string, + bad-continuation, + bad-whitespace, + bare-except, + broad-except, + dangerous-default-value, + expression-not-assigned, + fixme, + global-statement, + import-error, + invalid-name, + len-as-condition, + logging-format-interpolation, + lost-exception, + misplaced-comparison-constant, + missing-docstring, + missing-final-newline, + no-else-return, + #no-member, + no-self-use, + pointless-statement, + protected-access, + redefined-argument-from-local, + redefined-builtin, + redefined-outer-name, + superfluous-parens, + too-many-arguments, + too-many-boolean-expressions, + too-many-branches, + too-many-lines, + too-many-locals, + too-many-nested-blocks, + too-many-public-methods, + too-many-return-statements, + too-many-statements, + undefined-loop-variable, + ungrouped-imports, + unidiomatic-typecheck, + unnecessary-lambda, + unsupported-assignment-operation, + unused-argument, + unused-variable, + wrong-import-order, +[FORMAT] +max-line-length=139 diff --git a/.travis.yml b/.travis.yml index 4cc116c..925bbbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ addons: - zsh script: - python3 -m flake8 + - find . -iname "*.py" | xargs pylint --rcfile .pylintrc - python3 -m pytest ./tests/test_*.py --cov buku -vv - git fetch --unshallow --tags origin - ./tools/makedeb diff --git a/buku.py b/buku.py index 03fe82b..db0a1c4 100755 --- a/buku.py +++ b/buku.py @@ -474,7 +474,7 @@ class BukuDb: os.makedirs(dbpath) except Exception as e: logerr(e) - os.exit(1) + os._exit(1) db_exists = os.path.exists(dbfile) enc_exists = os.path.exists(dbfile + '.enc') diff --git a/setup.py b/setup.py index 8efc792..7456a94 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ with open('README.md', encoding='utf-8') as f: tests_require = [ 'pytest-cov', 'pytest-catchlog', 'hypothesis>=3.7.0', 'pytest>=3.1.2', 'py>=1.4.33', - 'beautifulsoup4==4.6.0', 'flake8>=3.4.1' + 'beautifulsoup4==4.6.0', 'flake8>=3.4.1', 'pylint>=1.7.2' ], setup( diff --git a/tox.ini b/tox.ini index dd04ae4..8c19171 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,8 @@ envlist = python33,python34,python35 commands = pip install -e .[tests] pip install -r requirements.txt + find . -iname "*.py" | xargs pylint --rcfile .pylintrc + ;find . -iname "*.py" -and -not -path './.tox/*' -not -path './build/*' | xargs pylint --rcfile .pylintrcp python -m flake8 pytest --cov buku -vv {posargs} ;pytest --cov buku -vv -m 'not slowtest and not non_tox'{posargs}