summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2017-04-26 00:23:01 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2017-04-25 22:23:01 -0700
commit11dae722c25e4b494615c10f899c6601e06694d4 (patch)
tree8791e74e7d9ef57939ef2621fd4d327d3c751103
parent33c9a91d853da82dccf3d244e06c0c3db0061c9a (diff)
downloadspack-11dae722c25e4b494615c10f899c6601e06694d4.tar.gz
spack-11dae722c25e4b494615c10f899c6601e06694d4.tar.bz2
spack-11dae722c25e4b494615c10f899c6601e06694d4.tar.xz
spack-11dae722c25e4b494615c10f899c6601e06694d4.zip
Fix bug with '# noqa' filtering (#3993)
-rw-r--r--lib/spack/spack/cmd/flake8.py13
-rw-r--r--var/spack/repos/builtin.mock/packages/flake8/package.py6
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/spack/spack/cmd/flake8.py b/lib/spack/spack/cmd/flake8.py
index 6cfd98dbb4..42d36a3beb 100644
--- a/lib/spack/spack/cmd/flake8.py
+++ b/lib/spack/spack/cmd/flake8.py
@@ -139,14 +139,6 @@ def filter_file(source, dest, output=False):
# We still want to catch trailing whitespace warnings
line = line.rstrip('\n')
- if line == '# flake8: noqa':
- # Entire file is ignored
- break
-
- if line.endswith('# noqa'):
- # Line is already ignored
- continue
-
for file_pattern, errors in exemptions.items():
if not file_pattern.search(source):
continue
@@ -154,7 +146,10 @@ def filter_file(source, dest, output=False):
for code, patterns in errors.items():
for pattern in patterns:
if pattern.search(line):
- if '# noqa: ' in line:
+ if line.endswith('# noqa'):
+ # Line is already ignored
+ pass
+ elif '# noqa: ' in line:
line += ',{0}'.format(code)
else:
line += ' # noqa: {0}'.format(code)
diff --git a/var/spack/repos/builtin.mock/packages/flake8/package.py b/var/spack/repos/builtin.mock/packages/flake8/package.py
index bd062d71bc..22598bead1 100644
--- a/var/spack/repos/builtin.mock/packages/flake8/package.py
+++ b/var/spack/repos/builtin.mock/packages/flake8/package.py
@@ -71,7 +71,11 @@ class Flake8(Package):
patch('hyper-specific-patch-that-fixes-some-random-bug-that-probably-only-affects-one-user.patch', when='%gcc@3.2.2:3.2.3')
def install(self, spec, prefix):
- pass
+ # Make sure lines with '# noqa' work as expected. Don't just
+ # remove them entirely. This will mess up the indentation of
+ # the following lines.
+ if 'really-long-if-statement' != 'that-goes-over-the-line-length-limit-and-requires-noqa': # noqa
+ pass
# '@when' decorated functions are exempt from redefinition errors
@when('@2.0')