Skip to content

Commit 29e9483

Browse files
authored
Merge pull request #3 from meengit/review-fixes
Review fixes
2 parents 0c7d527 + 8ec7aa6 commit 29e9483

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Within Sublime Text, bring up the [Command Palette][cmd] and type `install`. Amo
2626
When the plugin list appears, type `codeclimate`. Among the entries you should see `SublimeLinter-contrib-codeclimate`. If that entry is not highlighted, use the keyboard or mouse to select it.
2727

2828
## How it works
29-
If the first opened folder in SublimeText contains a `.codeclimate.yml` configuration file in its root, `codeclimate` will recognize this file's settings.
29+
If the opened folder in SublimeText contains a `.codeclimate.yml` configuration file in its root, `codeclimate` will recognize this file's settings.
3030

3131
Suppose the `codeclimate` CLI finds no configuration file in the folder root: In that case, it will automatically run the default inspections of `structure` and `duplication`. If you have a `.codeclimate.yml` configuration file in a different folder, you can set SublimeLinter's `working_dir` setting (please see examples).
3232

@@ -65,7 +65,7 @@ If you want to ignore the configuration of a `.codeclimate.yml`, for instance,
6565

6666
Suppose you use a `.codeclimate.yml`-configuration file. In that case, the `codeclimate` CLI needs to be executed in your configuration file's directory. Otherwise, it can't detect your configuration and runs only the default analyzes.
6767

68-
SublimeLinter takes the (first) open folder (or the folder of a single opened file) as the working directory for executing its linter commands. You can change this behavior by setting the working directory of execution:
68+
SublimeLinter takes the current file's root folder in SublimeText's sidebar as the working directory for executing its linter commands. You can change this behavior by setting the working directory of execution:
6969

7070
```json
7171
{

linter.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@
1111
#
1212

1313
"""This module exports the Codeclimate plugin class."""
14-
import logging
1514
import os
16-
from SublimeLinter.lint import Linter, util
17-
18-
19-
logger = logging.getLogger('SublimeLinter.plugin.eslint')
15+
from SublimeLinter.lint import Linter, PermanentError, util
2016

2117

2218
class Codeclimate(Linter):
2319
"""Provides an interface to codeclimate."""
2420
defaults = {
21+
'excludes': ['!${folder::}*'],
2522
'selector': (
2623
'source.css, '
2724
'source.go, '
@@ -37,8 +34,9 @@ class Codeclimate(Linter):
3734
'text.html'
3835
)
3936
}
40-
regex = r'^(?P<line>\d+)(?:-\d+)?:\s(?P<message>.+)$'
41-
multiline = False
37+
38+
regex = r'^== ((?P<filename>.*)(?= \(\d+ issue\) ==))( \(\d+ issue\) ==\n(?P<line>\d+))(?:-\d+)?:\s(?P<message>.+)$'
39+
multiline = True
4240
line_col_base = (1, 1)
4341
tempfile_suffix = '-'
4442
error_stream = util.STREAM_BOTH
@@ -49,24 +47,13 @@ def cmd(self):
4947
abs_path = self.filename
5048
working_dir = self.get_working_dir()
5149

52-
msg = 'You try to lint the file %s from outside of SublimeText\'s ' \
53-
'working directory (%s), which is not supported by this ' \
54-
'SublimeLinter plugin at this time. You can do either:\n' \
55-
'* You open the directory containing the current file in' \
56-
'a new window. You may have to add a customized ' \
57-
'`.codeclimate.yml` configuration to that directory ' \
58-
'as well;\n' \
59-
'* You change the working directory of the linter plugin in ' \
60-
' the global or the Project\'s settings;\n' \
61-
'* You disable the linter plugin in the global or the ' \
62-
'Project\'s settings.\n\n' \
63-
'Please visit https://github.com/codeclimate/' \
64-
'SublimeLinter-contrib-codeclimate for examples.' \
65-
'\n' % (abs_path, working_dir)
50+
msg = 'The file \'%s\' is not part of the working dir (%s). ' \
51+
'Please see the Linter\'s README.md to get further ' \
52+
'instructions.' % (abs_path, working_dir)
6653

6754
if not (abs_path.startswith(os.path.abspath(working_dir) + os.sep)):
68-
logger.info(msg)
69-
return None
55+
self.notify_unassign()
56+
raise PermanentError(msg)
7057

7158
file = os.path.relpath(abs_path, working_dir)
7259
return ['codeclimate', 'analyze', '${args}', file, '${xoo}']

0 commit comments

Comments
 (0)