diff options
-rwxr-xr-x | .gitlab/linters/check-makefiles.py | 3 | ||||
-rw-r--r-- | .gitlab/linters/linter.py | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/.gitlab/linters/check-makefiles.py b/.gitlab/linters/check-makefiles.py index 4e4924cdbc..0a82a99d41 100755 --- a/.gitlab/linters/check-makefiles.py +++ b/.gitlab/linters/check-makefiles.py @@ -12,7 +12,8 @@ from linter import run_linters, RegexpLinter linters = [ RegexpLinter(r'--interactive', - message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.") + message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`.", + path_filter = lambda path: path == 'Makefile') ] if __name__ == '__main__': 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) |