From 2aa4387ebac307285c1b2c90bc6527b82fe83839 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 10 May 2016 23:45:41 -0700 Subject: Update code style checking. - Exempt overlong URL lines from checks. - Omit some of the more painful PEP items. --- share/spack/qa/flake8-framework | 10 ++++++++++ share/spack/qa/flake8-packages | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 share/spack/qa/flake8-framework create mode 100644 share/spack/qa/flake8-packages (limited to 'share') diff --git a/share/spack/qa/flake8-framework b/share/spack/qa/flake8-framework new file mode 100644 index 0000000000..b1ad00b80f --- /dev/null +++ b/share/spack/qa/flake8-framework @@ -0,0 +1,10 @@ +# -*- conf -*- +[flake8] +# Descriptions of ignored checks: +# +# E221: multiple spaces before operator +# E241: multiple spaces after ‘,’ +# F403: disable wildcard import +# +ignore = E221,E241,F403 +max-line-length = 79 diff --git a/share/spack/qa/flake8-packages b/share/spack/qa/flake8-packages new file mode 100644 index 0000000000..0e5be249fb --- /dev/null +++ b/share/spack/qa/flake8-packages @@ -0,0 +1,11 @@ +# -*- conf -*- +[flake8] +# Descriptions of ignored checks: +# +# E221: multiple spaces before operator +# E241: multiple spaces after ‘,’ +# F403: disable wildcard import +# F821: undefined name (needed for build commands) +# +ignore = E221,E241,F403,F821 +max-line-length = 79 -- cgit v1.2.3-60-g2f50 From d7847ff7685a52670a9d01cf39bd44eff1a57684 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 11 May 2016 01:16:41 -0700 Subject: Use just one flake8 file; mark package.py files to avoid E501 w/url. --- .flake8 | 12 ++++++++++++ share/spack/qa/flake8-framework | 10 ---------- share/spack/qa/flake8-packages | 11 ----------- var/spack/repos/builtin/packages/ImageMagick/package.py | 2 +- 4 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 .flake8 delete mode 100644 share/spack/qa/flake8-framework delete mode 100644 share/spack/qa/flake8-packages (limited to 'share') diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000..ab1e14b66e --- /dev/null +++ b/.flake8 @@ -0,0 +1,12 @@ +# -*- conf -*- +[flake8] +# Descriptions of ignored checks: +# +# E221: multiple spaces before operator +# E241: multiple spaces after ‘,’ +# F403: disable wildcard import +# F821: undefined name (needed for build commands) +# F999: Undefined undefined name (needed for build commands) +# +ignore = E221,E241,F403,F821,F999 +max-line-length = 79 diff --git a/share/spack/qa/flake8-framework b/share/spack/qa/flake8-framework deleted file mode 100644 index b1ad00b80f..0000000000 --- a/share/spack/qa/flake8-framework +++ /dev/null @@ -1,10 +0,0 @@ -# -*- conf -*- -[flake8] -# Descriptions of ignored checks: -# -# E221: multiple spaces before operator -# E241: multiple spaces after ‘,’ -# F403: disable wildcard import -# -ignore = E221,E241,F403 -max-line-length = 79 diff --git a/share/spack/qa/flake8-packages b/share/spack/qa/flake8-packages deleted file mode 100644 index 0e5be249fb..0000000000 --- a/share/spack/qa/flake8-packages +++ /dev/null @@ -1,11 +0,0 @@ -# -*- conf -*- -[flake8] -# Descriptions of ignored checks: -# -# E221: multiple spaces before operator -# E241: multiple spaces after ‘,’ -# F403: disable wildcard import -# F821: undefined name (needed for build commands) -# -ignore = E221,E241,F403,F821 -max-line-length = 79 diff --git a/var/spack/repos/builtin/packages/ImageMagick/package.py b/var/spack/repos/builtin/packages/ImageMagick/package.py index 7a3d12e364..3a86d9fb7c 100644 --- a/var/spack/repos/builtin/packages/ImageMagick/package.py +++ b/var/spack/repos/builtin/packages/ImageMagick/package.py @@ -24,7 +24,7 @@ class Imagemagick(Package): version( '6.8.9-10', 'aa050bf9785e571c956c111377bbf57c', - url="http://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz/download") # NOQA: ignore=E501 + url="http://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz/download") depends_on('jpeg') depends_on('libtool') -- cgit v1.2.3-60-g2f50 From 78d25ad337e2faaa8cfd589607801acb78aec4d9 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 11 May 2016 02:01:24 -0700 Subject: Add run-flake8 script. - was missing the obvious. --- share/spack/qa/run-flake8 | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 share/spack/qa/run-flake8 (limited to 'share') diff --git a/share/spack/qa/run-flake8 b/share/spack/qa/run-flake8 new file mode 100755 index 0000000000..722c7fcba6 --- /dev/null +++ b/share/spack/qa/run-flake8 @@ -0,0 +1,55 @@ +#!/bin/bash +# +# This script runs source code style checks on Spack. +# +# It should be executed from the top-level directory of the repo, +# e.g.: +# +# share/spack/qa/run-flake8 +# +# To run it, you'll need to have the Python flake8 installed locally. +# +PYTHONPATH=./lib/spack:$PYTHONPATH + +flake8="$(which flake8)" +if [[ ! $flake8 ]]; then + echo "ERROR: flake8 is required to run this script." + exit 1 +fi + +# Check if changed files are flake8 conformant [framework] +changed=$(git diff --name-only develop... | grep '.py$') + +# Exempt url lines in changed packages from overlong line errors. +for file in $changed; do + if [[ $file = *package.py ]]; then + perl -i~ -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' $file; + fi +done + +return_code=0 +if [[ $changed ]]; then + echo ======================================================= + echo flake8: running flake8 code checks on spack. + echo + echo Modified files: + echo $changed | perl -pe 's/^/ /;s/ +/\n /g' + echo ======================================================= + if flake8 --format pylint $changed; then + echo "Flake8 checks were clean." + else + echo "Flake8 found errors." + return_code=1 + fi +else + echo No core framework files modified. +fi + +# Restore original package files after modifying them. +for file in $changed; do + if [[ $file = *package.py ]]; then + mv "${file}~" "${file}" + fi +done + +exit $return_code -- cgit v1.2.3-60-g2f50