Skip to content

Commit 60233b8

Browse files
committed
Update to Allow Bundle Exec
* Update to add preference to allow use of bundle exec
1 parent 1e23390 commit 60233b8

File tree

4 files changed

+57
-27
lines changed

4 files changed

+57
-27
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Version 1.2
2+
* Enable using `bundle exec` with rubocop.
3+
* Bug: fix error if there are no fixes from Rubocop.
4+
15
## Version 1.1
26

37
Add issue severity differentiation.

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ gem install rubocop rubocop-rails rubocop-rspec rubocop-md
2121

2222

2323
### Configuration
24+
* We now let you choose whether to prepend your rubocop with `bundle exec`. If you do not it will
25+
use `rubocop` from your default/global gemset.
2426

25-
Following the [Rails Doctrine](https://rubyonrails.org/doctrine/#convention-over-configuration)
26-
this extension does not require nor support configuration. It will use your global
27-
Rubocop installation.
27+
### Troubleshooting
28+
If you have a .rubocop.yml with `inherit_gem` and use `rvm` you will need to make sure your gems are
29+
all available in the default gemset. The easiest way to do this is to avoid using app specific
30+
gemsets. Otherwise try:
31+
32+
```sh
33+
cd $APP_DIRECTORY
34+
rvm use default
35+
bundle install
36+
```

Scripts/main.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
exports.activate = function() {
3-
3+
44
}
55

66
exports.deactivate = function() {
@@ -12,8 +12,14 @@ class IssuesProvider {
1212
return new Promise(function(resolve) {
1313
try {
1414
const options = {
15+
cwd: nova.workspace.path,
1516
args: ["rubocop", '--disable-pending-cops', '-fj', editor.document.path]
1617
};
18+
if(nova.config.get("Rubocop.bundle-exec", "boolean")) {
19+
options.args.unshift("bundle", "exec")
20+
}
21+
// console.log('Config: ' + nova.config.get("Rubocop.bundle-exec", "boolean"))
22+
// console.log("Options: " + options.args)
1723
let rubocop = new Process("/usr/bin/env", options);
1824
let rawIssues = []
1925
let issues = [];
@@ -25,24 +31,27 @@ class IssuesProvider {
2531
'convention': IssueSeverity.Hint,
2632
'info': IssueSeverity.Info
2733
}
28-
2934
rubocop.onStdout((line) => { rawIssues.push(line); });
30-
rubocop.onStderr((line) => { console.warn(`Rubocop ERROR: ${line}`); });
35+
rubocop.onStderr((line) => { console.error(`Rubocop ERROR: ${line}`); });
3136
rubocop.onDidExit((message) => {
32-
const allIssues = JSON.parse(rawIssues)['files'][0]['offenses'];
33-
allIssues.forEach((offense) => {
34-
let issue = new Issue();
35-
issue.message = offense['message']
36-
issue.code = offense['cop_name']
37-
issue.severity = issueSeverity[offense['severity']];
38-
issue.column = offense["location"]["start_column"]
39-
issue.endColumn = offense["location"]["end_column"]
40-
issue.line = offense["location"]["start_line"]
41-
issue.endLine = offense["location"]["end_line"]
42-
issues.push(issue);
43-
})
44-
resolve(issues);
45-
return;
37+
if(rawIssues.length === 0) {
38+
return;
39+
} else {
40+
const allIssues = JSON.parse(rawIssues)['files'][0]['offenses'];
41+
allIssues.forEach((offense) => {
42+
let issue = new Issue();
43+
issue.message = offense['message']
44+
issue.code = offense['cop_name']
45+
issue.severity = issueSeverity[offense['severity']];
46+
issue.column = offense["location"]["start_column"]
47+
issue.endColumn = offense["location"]["end_column"]
48+
issue.line = offense["location"]["start_line"]
49+
issue.endLine = offense["location"]["end_line"]
50+
issues.push(issue);
51+
})
52+
resolve(issues);
53+
return;
54+
}
4655
});
4756
rubocop.start();
4857
} catch(error) {
@@ -54,4 +63,4 @@ class IssuesProvider {
5463
}
5564
}
5665

57-
nova.assistants.registerIssueAssistant("ruby", new IssuesProvider(), {event: "onChange"});
66+
nova.assistants.registerIssueAssistant("ruby", new IssuesProvider(), {event: "onChange"});

extension.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33
"name": "RuboCop",
44
"organization": "Matt Zagaja",
55
"description": "Rubocop extension.",
6-
"version": "1.1",
7-
"categories": ["issues"],
6+
"version": "1.2",
7+
"categories": [
8+
"issues"
9+
],
810
"repository": "https://github.com/mzagaja/Rubocop.novaextension",
911
"bugs": "https://github.com/mzagaja/Rubocop.novaextension/issues",
10-
1112
"main": "main.js",
12-
1313
"activationEvents": [
1414
"onLanguage:ruby"
1515
],
16-
1716
"entitlements": {
1817
"process": true
19-
}
18+
},
19+
"config": [
20+
{
21+
"key": "Rubocop.bundle-exec",
22+
"title": "Prepend rubocop with bundle exec",
23+
"description": "Use this to prepend rubocop with bundle exec.",
24+
"type": "boolean",
25+
"default": false
26+
}
27+
]
2028
}

0 commit comments

Comments
 (0)