Skip to content

Commit

Permalink
[Fix #8252] Fix a typo for --safe-auto-correct command line option
Browse files Browse the repository at this point in the history
Fixes #8252.

This PR fixes a command line option name from `--safe-autocorrect`
to `--safe-auto-correct`, which is compatible with RuboCop 0.66 and lower.

Before:

```console
% bundle exec ./exe/rubocop --safe-auto-correct
invalid option: --safe-auto-correct
Did you mean?  safe-autocorrect
For usage information, use --help
```

After:

```console
% bundle exec ./exe/rubocop --safe-auto-correct
--safe-auto-correct is deprecated; use --auto-correct
Inspecting 1082 files
```
  • Loading branch information
koic authored and bbatsov committed Jul 7, 2020
1 parent 49788f6 commit 4c06394
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### Bug fixes

* [#8252](https://github.com/rubocop-hq/rubocop/issues/8252): Fix a command line option name from `--safe-autocorrect` to `--safe-auto-correct`, which is compatible with RuboCop 0.66 and lower. ([@koic][])

## 0.87.0 (2020-07-06)

### New features
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/options.rb
Expand Up @@ -174,8 +174,8 @@ def add_boolean_flags(opts)
option(opts, '-a', '--auto-correct') do
@options[:safe_auto_correct] = true
end
option(opts, '--safe-autocorrect') do
warn '--safe-autocorrect is deprecated; use --autocorrect'
option(opts, '--safe-auto-correct') do
warn '--safe-auto-correct is deprecated; use --auto-correct'
@options[:safe_auto_correct] = @options[:auto_correct] = true
end
option(opts, '-A', '--auto-correct-all') do
Expand Down Expand Up @@ -472,7 +472,7 @@ module OptionsHelp
safe: 'Run only safe cops.',
list_target_files: 'List all files RuboCop will inspect.',
auto_correct: 'Auto-correct offenses (only when it\'s safe).',
safe_autocorrect: '(same, deprecated)',
safe_auto_correct: '(same, deprecated)',
auto_correct_all: 'Auto-correct offenses (safe and unsafe)',
fix_layout: 'Run only layout cops, with auto-correct on.',
color: 'Force color output on or off.',
Expand Down
6 changes: 3 additions & 3 deletions spec/rubocop/options_spec.rb
Expand Up @@ -115,7 +115,7 @@ def abs(path)
-E, --extra-details Display extra details in offense messages.
-S, --display-style-guide Display style guide URLs in offense messages.
-a, --auto-correct Auto-correct offenses (only when it's safe).
--safe-autocorrect (same, deprecated)
--safe-auto-correct (same, deprecated)
-A, --auto-correct-all Auto-correct offenses (safe and unsafe)
--disable-pending-cops Run without pending cops.
--enable-pending-cops Run with pending cops.
Expand Down Expand Up @@ -372,9 +372,9 @@ def abs(path)
end
end

describe '--safe-autocorrect' do
describe '--safe-auto-correct' do
it 'is a deprecated alias' do
expect { options.parse %w[--safe-autocorrect] }
expect { options.parse %w[--safe-auto-correct] }
.to output(/deprecated/).to_stderr
end
end
Expand Down

0 comments on commit 4c06394

Please sign in to comment.