Securedrop: Provide Makefile target for running flake8 tests

Created on 30 Jun 2017  路  3Comments  路  Source: freedomofpress/securedrop

Feature request

Description

Recently a number of flake8-compatibility PRs have landed, increasing PEP8 compliance throughout the app code. We've smartly added the flake8ified files to Travis CI, to guard against regressions in style and formatting.

It's still difficult to run flake8 against only the already compliant files. I suggest adding a make flake8 target that would handle a DRY declaration of the Python files, and can be reused in Travis CI, as well.

We still have a number of flake8-related PRs open (#1906, #1908, #1909, #1911, #1914, etc.), so let's wait until merge churn has settled down a bit before implementing this.

User Stories

As a developer, I want to test the changes I've made locally prior to opening a PR. Grepping through a Travis YAML file for the correct filenames to run flake8 against gets old fast, but Makefiles can save the day.

tests

Most helpful comment

I'm hopeful flake8 securedrop will work soon enough and save us the trouble of designating each file individually :-)

All 3 comments

Something like this:

diff --git a/Makefile b/Makefile
index b4d13934..d59e7efe 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,20 @@ ci-debug:
 ci-build-only:
    ./devops/scripts/ci-build_only.sh

+.PHONY: flake8
+flake8:
+# We're working toward full PEP8 compliance throughout the codebase,
+# but in the meantime let's enforce linting on select files, to minimize
+# regressions and gradually expand the compliance.
+   flake8 \
+       securedrop/crypto_util.py \
+       securedrop/db.py \
+       securedrop/source.py \
+       securedrop/store.py \
+       securedrop/template_filters.py \
+       securedrop/tests/test_2fa.py \
+       securedrop/tests/test_crypto_util.py
+
 .PHONY: docs-lint
 docs-lint:
 # The `-W` option converts warnings to errors.

I'm hopeful flake8 securedrop will work soon enough and save us the trouble of designating each file individually :-)

Even if we have full PEP8 compliance in all the SecureDrop app code (:tada:), a Makefile target is still useful for developers. E.g. a make flake8 target could run against the securedrop/ directory, and possibly others as well (e.g. testinfra/). Then a wrapper target e.g. make lint could run the flake8 target and also yamllint or shellcheck (#1366).

Was this page helpful?
0 / 5 - 0 ratings