From b5cb94b88dc514a484d82e439ae6090cf4a8ca2f Mon Sep 17 00:00:00 2001 From: Chao Yang Date: Sat, 28 Oct 2017 21:54:36 -0500 Subject: [PATCH 1/5] Add forceExclusion flag to rubocop setting --- readme.md | 3 ++- src/lint/lib/linters/RuboCop.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 65d07c600..a5cea3f90 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ [![Join the chat at https://rubyide-slackin.azurewebsites.net](./images/badge.png)](https://rubyide-slackin.azurewebsites.net) [![Build Status](https://api.travis-ci.org/rubyide/vscode-ruby.svg?branch=master)](https://travis-ci.org/rubyide/vscode-ruby) [![Build status](https://ci.appveyor.com/api/projects/status/vlgs2y7tsc4xpj4c?svg=true)](https://ci.appveyor.com/project/rebornix/vscode-ruby) -This extension provides rich Ruby language and debugging support for VS Code. It's still in progress ( [GitHub](https://github.com/rubyide/vscode-ruby.git) ), please expect frequent updates with breaking changes before 1.0. +This extension provides rich Ruby language and debugging support for VS Code. It's still in progress ( [GitHub](https://github.com/rubyide/vscode-ruby.git) ), please expect frequent updates with breaking changes before 1.0. It started as a personal project of [@rebornix](https://github.com/rebornix), aiming to bring Ruby debugging experience to VS Code. Then it turned to be a community driven project. With his amazing commits, [@HookyQR](https://github.com/HookyQR) joined as a contributor and brought users Linting/Formatting/etc, made the debugger more robust and more! If you are interested in this project, feel free to join the [community](https://github.com/rubyide/vscode-ruby/graphs/contributors): file [issues](https://github.com/rubyide/vscode-ruby/issues/new), fork [our project](https://github.com/rubyide/vscode-ruby) and hack it around and send us PRs, or subscribe to our [mailing list](http://eepurl.com/bTBAfv). @@ -106,6 +106,7 @@ Settings available (in your VSCode workspace) for each of the linters: "lint": true, //enable all lint cops. "only": [/* array: Run only the specified cop(s) and/or cops in the specified departments. */], "except": [/* array: Run all cops enabled by configuration except the specified cop(s) and/or departments. */], + "forceExclusion": true, //Add --force-exclusion option "require": [/* array: Require Ruby files. */], "rails": true //Run extra rails cops } diff --git a/src/lint/lib/linters/RuboCop.js b/src/lint/lib/linters/RuboCop.js index d0b1b68da..f4cf51a68 100644 --- a/src/lint/lib/linters/RuboCop.js +++ b/src/lint/lib/linters/RuboCop.js @@ -8,6 +8,7 @@ function RuboCop(opts) { this.args = ["-s", "{path}", "-f", "json"] ; + if (opts.forceExclusion) this.args.push("--force-exclusion") if (opts.lint) this.args.push("-l"); if (opts.only) this.args = this.args.concat("--only", opts.only.join(',')); if (opts.except) this.args = this.args.concat("--except", opts.except.join(',')); @@ -20,6 +21,9 @@ RuboCop.prototype.processResult = function (data) { return []; } let offenses = JSON.parse(data); + if (offenses.summary.offense_count == 0) { + return []; + } return (offenses.files || [{ offenses: [] }])[0].offenses; From fc7a53e7bc788a6e3bd8eafae182f7d63a4a786e Mon Sep 17 00:00:00 2001 From: Chao Yang Date: Sat, 28 Oct 2017 23:39:23 -0500 Subject: [PATCH 2/5] Fix tests. --- .travis.yml | 2 +- src/lint/lib/linters/RuboCop.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb29b5fa0..c6dd7cd3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ before_install: - nvm install v6.9.1 - nvm use v6.9.1 before_script: - - npm install -g typescript -v 2.1.5 + - npm install -g typescript@2.1.5 - npm install - tsc -p ./src script: npm run test-debugger diff --git a/src/lint/lib/linters/RuboCop.js b/src/lint/lib/linters/RuboCop.js index f4cf51a68..a4b443a1e 100644 --- a/src/lint/lib/linters/RuboCop.js +++ b/src/lint/lib/linters/RuboCop.js @@ -8,7 +8,7 @@ function RuboCop(opts) { this.args = ["-s", "{path}", "-f", "json"] ; - if (opts.forceExclusion) this.args.push("--force-exclusion") + if (opts.forceExclusion) this.args.push("--force-exclusion"); if (opts.lint) this.args.push("-l"); if (opts.only) this.args = this.args.concat("--only", opts.only.join(',')); if (opts.except) this.args = this.args.concat("--except", opts.except.join(',')); From a2391d5a58c251f829ef55d075f80dc4660afb58 Mon Sep 17 00:00:00 2001 From: Chao Yang Date: Sat, 28 Oct 2017 23:43:49 -0500 Subject: [PATCH 3/5] Change space to tab --- src/lint/lib/linters/RuboCop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lint/lib/linters/RuboCop.js b/src/lint/lib/linters/RuboCop.js index a4b443a1e..550681608 100644 --- a/src/lint/lib/linters/RuboCop.js +++ b/src/lint/lib/linters/RuboCop.js @@ -23,7 +23,7 @@ RuboCop.prototype.processResult = function (data) { let offenses = JSON.parse(data); if (offenses.summary.offense_count == 0) { return []; - } + } return (offenses.files || [{ offenses: [] }])[0].offenses; From b1bf3c0a9bc420556649fd8d06b27fd3d05393bd Mon Sep 17 00:00:00 2001 From: Chao Yang Date: Sun, 29 Oct 2017 00:10:47 -0500 Subject: [PATCH 4/5] Fix tsc error --- src/ruby.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ruby.ts b/src/ruby.ts index cb03de6fe..8303e40b2 100644 --- a/src/ruby.ts +++ b/src/ruby.ts @@ -32,7 +32,7 @@ export function activate(context: ExtensionContext) { function getGlobalConfig() { let globalConfig = {}; - let rubyInterpreterPath = vscode.workspace.getConfiguration("ruby.interpreter").commandPath; + let rubyInterpreterPath = (vscode.workspace.getConfiguration("ruby.interpreter") as any).commandPath; if (rubyInterpreterPath) { globalConfig["rubyInterpreterPath"] = rubyInterpreterPath; } @@ -108,7 +108,7 @@ function registerHighlightProvider(ctx: ExtensionContext) { function registerLinters(ctx: ExtensionContext) { const globalConfig = getGlobalConfig(); - const linters = new LintCollection(globalConfig, vscode.workspace.getConfiguration("ruby").lint, vscode.workspace.rootPath); + const linters = new LintCollection(globalConfig, (vscode.workspace.getConfiguration("ruby") as any).lint, vscode.workspace.rootPath); ctx.subscriptions.push(linters); function executeLinting(e: vscode.TextEditor | vscode.TextDocumentChangeEvent) { @@ -122,7 +122,7 @@ function registerLinters(ctx: ExtensionContext) { const docs = vscode.window.visibleTextEditors.map(editor => editor.document); console.log("Config changed. Should lint:", docs.length); const globalConfig = getGlobalConfig(); - linters.cfg(vscode.workspace.getConfiguration("ruby").lint, globalConfig); + linters.cfg((vscode.workspace.getConfiguration("ruby") as any).lint, globalConfig); docs.forEach(doc => linters.run(doc)); })); From 5731ef0ad029d831a7fc54fdaa0c83560c8a8bdb Mon Sep 17 00:00:00 2001 From: Chao Yang Date: Mon, 13 Nov 2017 20:59:19 -0600 Subject: [PATCH 5/5] Convert spaces to tabs --- src/lint/lib/linters/RuboCop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lint/lib/linters/RuboCop.js b/src/lint/lib/linters/RuboCop.js index 550681608..96c1cce08 100644 --- a/src/lint/lib/linters/RuboCop.js +++ b/src/lint/lib/linters/RuboCop.js @@ -22,7 +22,7 @@ RuboCop.prototype.processResult = function (data) { } let offenses = JSON.parse(data); if (offenses.summary.offense_count == 0) { - return []; + return []; } return (offenses.files || [{ offenses: []