Skip to content

Commit

Permalink
Merge pull request #11 from ajmichels/per-project-cmd
Browse files Browse the repository at this point in the history
add support for defining cmd on a per-project level
  • Loading branch information
ajmichels committed Mar 18, 2016
2 parents 0c022c7 + 4380bb4 commit 3a8b325
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ To install via Package Control, do the following:
## Settings
For general information on how SublimeLinter works with settings, please see [Settings](http://sublimelinter.readthedocs.org/en/latest/settings.html). For information on generic linter settings, please see [Linter Settings](http://sublimelinter.readthedocs.org/en/latest/linter_settings.html).

### Project Specific Executable
It is possible to specify the `phpcs` executable that should be used to lint your code on a per-project level.

**Example:**
```json
{
"SublimeLinter": {
"linters": {
"phpmd": {
"cmd": "${project}/vendor/bin/phpmd"
}
}
}
}
```

## Contributing
If you would like to contribute enhancements or fixes, please do the following:

Expand Down
17 changes: 16 additions & 1 deletion linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@


class Phpmd(Linter):

"""Provides an interface to phpmd."""

syntax = ('php', 'html', 'html 5')
cmd = 'phpmd @ text'
executable = 'phpmd'
regex = (
r'(?P<filename>.+):(?P<line>\d+)'
r'\s*(?P<message>.+)$'
Expand All @@ -30,3 +30,18 @@ class Phpmd(Linter):
}
inline_overrides = 'rulesets'
comment_re = r'\s*<!--'

def cmd(self):
"""Create the cmd."""
settings = Linter.get_view_settings(self)

# attempt to get the command from settings if it is present
if 'cmd' in settings:
command = [settings.get('cmd')]
else:
command = [self.executable_path]

command.append('@')
command.append('text')

return command
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"install": "messages/install.txt"
"install": "messages/install.txt",
"1.1.0": "messages/1.1.0.txt"
}
15 changes: 15 additions & 0 deletions messages/1.1.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SublimeLinter-phpmd 1.1.0
---------------------------

This version adds support for declaring per-project linter executable files.

Example (*.sublime-project):
{
"SublimeLinter": {
"linters": {
"phpmd": {
"cmd": "${project}/vendor/bin/phpmd"
}
}
}
}

0 comments on commit 3a8b325

Please sign in to comment.