-
Notifications
You must be signed in to change notification settings - Fork 9
/
linter.py
31 lines (26 loc) · 1.03 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
from SublimeLinter.lint import Linter, WARNING
class Phpmd(Linter):
regex = (
r'(.+):(?P<line>\d+)\s*(?P<message>.+)$'
)
on_stderr = None # handle stderr via regex
default_type = WARNING
tempfile_suffix = 'php'
defaults = {
'real_file_mode': False,
'selector': 'embedding.php, source.php',
'@rulesets:,': 'cleancode,codesize,controversial,design,naming,unusedcode'
}
@classmethod
def should_lint(cls, view, settings, reason):
# type: (sublime.View, LinterSettings, Reason) -> bool
"""Decide whether the linter can run at this point in time."""
if settings['real_file_mode'] and (
view.is_dirty() or not view.file_name()
):
return False
return super().should_lint(view, settings, reason)
def cmd(self):
target = '$file_on_disk' if self.settings['real_file_mode'] else '$temp_file'
self.tempfile_suffix = '-' if self.settings['real_file_mode'] else 'php'
return ('phpmd', target, 'text')