-
Notifications
You must be signed in to change notification settings - Fork 1
Updated Linter #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
33d2c30
a17fd42
41fcee0
42c2145
4cb246c
7314e2d
84d5732
fabc1f8
7961905
354aea6
e44f271
b000bc8
b781a48
0c7d527
159dd24
e19c458
987473f
8ec7aa6
29e9483
c44c78a
b7fa651
281e165
05597a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,19 @@ | ||
| # | ||
| # linter.py | ||
| # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 | ||
| # Linter for SublimeLinter4, a code checking framework for Sublime Text 3 | ||
| # | ||
| # Written by Noah Davis | ||
| # Copyright (c) 2016 Noah Davis | ||
| # | ||
| # Updated by Schuyler Jager & Andreas for SublimeLinter 4 | ||
| # Copyright (c) 2020 Schuyler Jager & Andreas | ||
| # License: MIT | ||
| # | ||
|
|
||
| """This module exports the Codeclimate plugin class.""" | ||
|
|
||
| from SublimeLinter.lint import Linter, util, persist | ||
| import re | ||
| from SublimeLinter.lint import Linter, util | ||
|
|
||
|
|
||
| class Codeclimate(Linter): | ||
|
|
@@ -41,15 +44,16 @@ class Codeclimate(Linter): | |
| error_stream = util.STREAM_BOTH | ||
| word_re = None | ||
|
|
||
| root = None | ||
| path = None | ||
|
|
||
| def cmd(self): | ||
| """Construct a cmd to provide a relative path to 'codeclimate analyze'.""" | ||
| result = ['codeclimate', 'analyze', '-e', 'structure', '-e', 'duplication'] | ||
| relative_file_name = None | ||
| for folder in self.view.window().folders(): | ||
| if self.filename.find(folder) == 0: | ||
| relative_file_name = self.filename.replace(folder + '/', '') | ||
| if relative_file_name == None: | ||
| return result | ||
| result.append(relative_file_name) | ||
| persist.debug(result) | ||
| return result | ||
| """Set working directory and run 'codeclimate analyze'.""" | ||
| if self.context.get('project_root') is None: | ||
|
||
| self.defaults['chdir'] = '${folder}' \ | ||
| if self.context.get('folder') is not None \ | ||
| else '${file_path}' | ||
|
|
||
| root = re.search(r"\{(\w+)\}", self.defaults['chdir']).group(1) | ||
| path = self.filename.replace(self.context.get(root) + '/', '') | ||
| return ['codeclimate', 'analyze', path] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fork is purpose-built to only run the
structureandduplicationengines.Maybe it would be beneficial to accept some user settings that can set these flags instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why the flags are defined here is because CodeClimate will run extra engines if they're defined in
.codeclimate.yml- which I don't need them to in my local environment because I have other linters for them (e.g. Rubocop)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @schuylr
Thank you very much for your response.
As far as I can see in my tests, and I experienced the behavior of SublimeLinter, arguments take place in the SublimeLinter settings. They will be applied either of global settings or project-specific settings. I've tested both. If you set for instance
in the global settings, codeclimate will ignore the
.codeclimate.ymlin the project root because it will be executed with arguments ($ codeclimate analyze path/to/file.ext -e structure -e duplication)I suggest, to take this way of using the SublimeLinter settings as it is designed, instead of "hard coding" the arguments.