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
This commit is contained in:
rachmadani haryono 2017-08-12 19:26:59 +08:00 committed by Arun Prakash Jana
parent 539f96eb65
commit 8afba2d826
6 changed files with 54 additions and 4 deletions

View File

@ -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.

47
.pylintrc Normal file
View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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(

View File

@ -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}