Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
b5ea9323
Commit
b5ea9323
authored
Jun 12, 2019
by
Ben Gamari
🐢
Committed by
Marge Bot
Jun 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lint: Only apply --interactive lint to testsuite .T files
parent
503e830c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
.gitlab/linters/check-makefiles.py
.gitlab/linters/check-makefiles.py
+4
-3
.gitlab/linters/linter.py
.gitlab/linters/linter.py
+14
-4
No files found.
.gitlab/linters/check-makefiles.py
View file @
b5ea9323
...
...
@@ -12,9 +12,10 @@ from linter import run_linters, RegexpLinter
linters
=
[
RegexpLinter
(
r
'--interactive'
,
message
=
"Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`."
,
path_filter
=
lambda
path
:
path
==
'Makefile
'
)
message
=
"Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`."
).
add_
path_filter
(
lambda
path
:
path
.
suffix
==
'.T
'
)
]
if
__name__
==
'__main__'
:
run_linters
(
linters
,
subdir
=
'testsuite'
)
run_linters
(
linters
,
subdir
=
'testsuite'
)
.gitlab/linters/linter.py
View file @
b5ea9323
...
...
@@ -7,7 +7,8 @@ import sys
import
re
import
textwrap
import
subprocess
from
typing
import
List
,
Optional
from
pathlib
import
Path
from
typing
import
List
,
Optional
,
Callable
from
collections
import
namedtuple
def
lint_failure
(
file
,
line_no
,
line_content
,
message
):
...
...
@@ -46,12 +47,21 @@ class Linter(object):
"""
def
__init__
(
self
):
self
.
warnings
=
[]
# type: List[Warning]
self
.
path_filters
=
[]
# type: List[Callable[[Path], bool]]
def
add_warning
(
self
,
w
:
Warning
):
self
.
warnings
.
append
(
w
)
def
add_path_filter
(
self
,
f
:
Callable
[[
Path
],
bool
])
->
"Linter"
:
self
.
path_filters
.
append
(
f
)
return
self
def
do_lint
(
self
,
path
):
if
all
(
f
(
path
)
for
f
in
self
.
path_filters
):
self
.
lint
(
path
)
def
lint
(
self
,
path
):
pass
raise
NotImplementedError
class
LineLinter
(
Linter
):
"""
...
...
@@ -66,7 +76,7 @@ class LineLinter(Linter):
self
.
lint_line
(
path
,
line_no
+
1
,
line
)
def
lint_line
(
self
,
path
,
line_no
,
line
):
pass
raise
NotImplementedError
class
RegexpLinter
(
LineLinter
):
"""
...
...
@@ -97,7 +107,7 @@ def run_linters(linters: List[Linter],
if
path
.
startswith
(
'.gitlab/linters'
):
continue
for
linter
in
linters
:
linter
.
lint
(
path
)
linter
.
do_
lint
(
path
)
warnings
=
[
warning
for
linter
in
linters
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment