Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ Specify configuration (via navigating to `File > Preferences > Workspace Setting
// "ruby.rubocop.executePath": "/Users/you/.rvm/gems/ruby-2.3.2/bin/"
// "ruby.rubocop.executePath": "D:/bin/Ruby22-x64/bin/"

// Set to "--auto-correct-all" to enable "unsafe" auto-corrections
"ruby.rubocop.autocorrectArg": "--auto-correct",

// If not specified, it assumes a null value by default.
"ruby.rubocop.configFilePath": "/path/to/config/.rubocop.yml",

// default true
// default: true
"ruby.rubocop.onSave": true
}
```
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
"default": "",
"description": "execution path of rubocop."
},
"ruby.rubocop.autocorrectArg": {
"type": "string",
"default": "--auto-correct",
"description": "RuboCop argument for autocorrect. Use --auto-correct-all to include unsafe autocorrections."
},
"ruby.rubocop.configFilePath": {
"type": "string",
"default": "",
Expand Down
2 changes: 2 additions & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Rubocop } from './rubocop';

export interface RubocopConfig {
command: string;
autocorrectArg: string;
onSave: boolean;
configFilePath: string;
useBundler: boolean;
Expand Down Expand Up @@ -70,6 +71,7 @@ export const getConfig: () => RubocopConfig = () => {

return {
command,
autocorrectArg: conf.get('autocorrectArg', '--auto-correct'),
configFilePath: conf.get('configFilePath', ''),
onSave: conf.get('onSave', true),
useBundler,
Expand Down
2 changes: 1 addition & 1 deletion src/rubocop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class RubocopAutocorrectProvider
try {
const args = [
...getCommandArguments(document.fileName),
'--auto-correct',
config.autocorrectArg, // Default: --auto-correct
];
const options = {
cwd: getCurrentPath(document.uri),
Expand Down
7 changes: 7 additions & 0 deletions test/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ vsStub.workspace.getConfiguration = (
const defaultConfig = {
configfilePath: '',
executePath: '',
autocorrectArg: '--auto-correct',
onSave: true,
useBundler: false,
suppressRubocopWarnings: false,
Expand Down Expand Up @@ -135,6 +136,12 @@ describe('RubocopConfig', () => {
expect(getConfig()).to.have.property('onSave');
});
});

describe('.autocorrectArg', () => {
it('is set', () => {
expect(getConfig().autocorrectArg).to.eq('--auto-correct');
});
});
});
});
});