Skip to content

Commit 0ff1df4

Browse files
committed
Switch to standard text format and adjust regex
Fixes SublimeLinter/SublimeLinter#1986 - The column is optional but we need to expect possible trailing ":". From ale, we copy that there might be multiple colons. - Capture the linter name and treat it like "code". In case the linter is "typecheck" treat it as "error". In general, this regex might be slower but also resilient *if* no linter is actually printed.
1 parent a1be8cf commit 0ff1df4

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

linter.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,28 @@
22

33

44
class GolangCILint(Linter):
5-
def cmd(self):
6-
if self.settings.get("v1", False):
7-
return 'golangci-lint run ${args} --out-format tab ${file_path}'
8-
return 'golangci-lint run ${args} --output.tab.path stdout ${file_path}'
95
tempfile_suffix = '-'
10-
# Column reporting is optional and not provided by all linters.
11-
# Issues reported by the 'typecheck' linter are treated as errors,
12-
# because they indicate code that won't compile. All other linter issues
13-
# are treated as warnings.
14-
regex = r'^(?P<filename>(\w+:\\\\)?.[^:]+):(?P<line>\d+)(:(?P<col>\d+))?\s+' + \
15-
r'(?P<code>(?P<error>typecheck)|\w+)\s+(?P<message>.+)$'
6+
regex = (
7+
r'^(?P<filename>(?:\w:)?[^:]+):'
8+
# Column reporting is optional and not provided by all linters.
9+
r'(?P<line>\d+)(?::(?P<col>\d+))?:*\s+'
10+
r'(?P<message>.+?)'
11+
# Issues reported by the 'typecheck' linter are treated as errors,
12+
# because they indicate code that won't compile.
13+
r'(?:\s+\((?:(?P<error>typecheck)|(?P<code>[^()]+))\))?$'
14+
)
15+
# All other linter issues are treated as warnings.
1616
default_type = WARNING
1717
defaults = {
1818
'selector': 'source.go',
1919
}
20+
21+
def cmd(self):
22+
if self.settings.get("v1", False):
23+
return 'golangci-lint run ${args} --out-format text ${file_path}'
24+
return (
25+
'golangci-lint run ${args}'
26+
' --output.text.path=stdout'
27+
' --show-stats=0'
28+
' ${file_path}'
29+
)

0 commit comments

Comments
 (0)