-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlinter.py
90 lines (68 loc) · 2 KB
/
linter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#
# linter.py
# Linter for SublimeLinter 3, a code checking framework for Sublime Text 3
#
# Written by ckaznocha
# Copyright (c) 2014 ckaznocha
#
# License: MIT
#
"""This module exports the CFLint plugin class."""
import logging
from SublimeLinter.lint import Linter
logger = logging.getLogger('SublimeLinter.plugin.eslint')
class CFLint(Linter):
"""Provides an interface to CFLint."""
regex = r'''(?xi)
# Severity
^\s*Severity:(?:(?P<warning>(WARNING|CAUTION|INFO|COSMETIC))|(?P<error>(FATAL|CRITICAL|ERROR)))\s*$\r?\n
# Message code
^.*$\r?\n
# File name
^.*$\r?\n
# Column number
^\s*Column:(?P<col>\d+)\s*$\r?\n
# Line number
^\s*Line:(?P<line>\d+)\s*$\r?\n
# Message
^\s*Message:(?P<message>.+)$\r?\n
# Variable
^.*$\r?\n
# Expression
^.*$\r?\n
'''
multiline = True
word_re = r'^<?(#?[-\w]+#?)'
defaults = {
'selector': 'embedding.cfml, source.cfml, source.cfscript, text.html.cfm',
'jar': '',
'-configfile': ''
}
def cmd(self):
jar = self.settings.get('jar')
if not jar:
logger.error(jar_file_missing_error_message)
return None
return [
'java', '-jar', jar,
'-stdin', '${file}',
'-stdout',
'-text',
'-q',
'${args}'
]
jar_file_missing_error_message = """
You MUST set the `jar` setting. It should point to your 'CFLint-*-all.jar'.
The absolute path is usually necessary unless this file is right in your working
dir.
E.g. for the global SublimeLinter settings:
"linters": {
"cflint": {
"jar": "path/to/CFLint-1.4.0-all.jar"
}
}
In project settings, you would use something like this:
"settings": {
"SublimeLinter.linters.cflint.jar": "path/to/CFLint-1.4.0-all.jar"
}
"""