summaryrefslogtreecommitdiff
path: root/.gitlab/linters/linter.py
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-09 10:36:58 -0400
committerBen Gamari <ben@smart-cactus.org>2019-06-12 08:20:25 -0400
commita798c130b3adc6c336856243a14175d4bd7c770f (patch)
treeb29a8e5bee58bf4ba29915086c4b1c27a424267f /.gitlab/linters/linter.py
parentb09374a4a839c2587a738698133465c4b9277c3b (diff)
downloadhaskell-a798c130b3adc6c336856243a14175d4bd7c770f.tar.gz
linters/check-makefiles: Limit lint to Makefiles
Previously we would apply this rule, which is only intended for testsuite Makefiles, to all files. This lead to a number of false-positives in all.T files.
Diffstat (limited to '.gitlab/linters/linter.py')
-rw-r--r--.gitlab/linters/linter.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/.gitlab/linters/linter.py b/.gitlab/linters/linter.py
index ec4f3581a8..a5cdd179b7 100644
--- a/.gitlab/linters/linter.py
+++ b/.gitlab/linters/linter.py
@@ -73,13 +73,14 @@ class RegexpLinter(LineLinter):
A :class:`RegexpLinter` produces the given warning message for
all lines matching the given regular expression.
"""
- def __init__(self, regex, message):
+ def __init__(self, regex, message, path_filter=lambda path: True):
LineLinter.__init__(self)
self.re = re.compile(regex)
self.message = message
+ self.path_filter = path_filter
def lint_line(self, path, line_no, line):
- if self.re.search(line):
+ if self.path_filter(path) and self.re.search(line):
w = Warning(path=path, line_no=line_no, line_content=line[:-1],
message=self.message)
self.add_warning(w)