From 97265549180bb9ba677c69032448243efdc34b0e Mon Sep 17 00:00:00 2001 From: bcaller Date: Wed, 25 Jul 2018 10:07:25 +0100 Subject: [PATCH 1/2] Remove unused import In commit 11bcd2d Remove unused function: valid_date an unused import was left in. With the next commit, tox & travis should fail: F401 'datetime.datetime' imported but unused --- pyt/usage.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyt/usage.py b/pyt/usage.py index a4ec5d81..7325a7c8 100644 --- a/pyt/usage.py +++ b/pyt/usage.py @@ -1,7 +1,6 @@ import argparse import os import sys -from datetime import datetime default_blackbox_mapping_file = os.path.join( From d55cbc035a72e974de4de4c656b9b3b5ca5ee529 Mon Sep 17 00:00:00 2001 From: bcaller Date: Tue, 24 Jul 2018 15:03:02 +0100 Subject: [PATCH 2/2] Tox, travis and requirements Requirements: Requirements files aren't used. Requirements.txt and setup.py had odd requirements that I can't see used anywhere. Requirements-dev.txt had conflicting packages (flake8 wants specific versions of pyflakes and pycodestyle). Tox & travis: Split tox into a test, coverage and lint phase. Run either: tox tox -e py36 tox -e cover tox -e lint Tox and travis will now fail the lint / build on flake8 errors to avoid non-compliant code being merged. (--exit-zero removed) Coverage will fail for now, so let's set it really low in travis for now. McCabe complexity is annoying and dealt with better by codeclimate so I bumped it up from 10 to 11 so it won't fail at the moment. --- .travis.yml | 9 ++++----- requirements-dev.txt | 8 -------- requirements.txt | 4 ---- setup.py | 6 +----- tox.ini | 20 ++++++++++++++++---- 5 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml index 079eef72..0638ada6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,14 @@ language: python python: - "3.6" install: - - pip install -r requirements.txt - - pip install codeclimate-test-reporter flake8 + - pip install codeclimate-test-reporter 'coverage>=4.0,<4.4' flake8 before_script: # stop the build if there are Python syntax errors or undefined names - flake8 . --count --exclude=examples --select=E901,E999,F821,F822,F823 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - - flake8 . --count --exclude=examples --exit-zero --max-complexity=10 --max-line-length=127 --statistics script: - - python -m tests - coverage run -m tests + - flake8 . --count --exclude=examples --max-complexity=11 --max-line-length=127 --show-source --statistics + - coverage report --include=tests/* --fail-under 100 + - coverage report --include=pyt/* --fail-under 91 after_script: - codeclimate-test-reporter diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 54e84f37..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,8 +0,0 @@ -flake8 -mock -pre-commit -py -pycodestyle -pyflakes -tox -virtualenv diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index f7b38d47..00000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -coverage>=4.0, <4.4 -GitPython==2.0.8 -graphviz==0.4.10 -requests~=2.12 diff --git a/setup.py b/setup.py index 39aa9440..17c81594 100644 --- a/setup.py +++ b/setup.py @@ -30,11 +30,7 @@ 'Programming Language :: Python :: 3.6' ], keywords=['security', 'vulnerability', 'web', 'flask', 'django', 'static-analysis', 'program-analysis'], - install_requires=[ - 'graphviz>=0.4.10', - 'requests>=2.12', - 'GitPython>=2.0.8' - ], + install_requires=[], entry_points={ 'console_scripts': [ 'pyt = pyt:main' diff --git a/tox.ini b/tox.ini index aa701c72..9ea660f5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,26 @@ [tox] -envlist = py36 +envlist = py36,cover,lint [testenv] +deps = mock +commands = + python -m tests + +[testenv:cover] whitelist_externals = coverage -deps = -rrequirements-dev.txt +deps = + coverage>=4.0,<4.4 + mock commands = coverage erase coverage run tests coverage report --include=tests/* --fail-under 100 coverage report --include=pyt/* --fail-under 91 + +[testenv:lint] +deps = + flake8 + pre-commit +commands = pre-commit run - flake8 . --count --exclude=examples,venv,.tox --select=E901,E999,F821,F822,F823 --show-source --statistics - flake8 . --count --exclude=examples,venv,.tox,dist --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --count --exclude=examples,.env,venv,.tox --show-source --statistics --max-complexity=11 --max-line-length=127 --statistics