Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a suggestion message when not auto-correctable
This PR fixes a suggestion message when not auto-correctable. RuboCop can specify `AutoCorrect: false`. In this case, even though auto-correct will not possible, auto-correct will be suggested. The following sets `AutoCorrect: false` to `Style/StringLiterals`. ```console % cat .rubocop.yml Style/StringLiterals: AutoCorrect: false % cat example.rb # frozen_string_literal: true puts "hello" ``` ## Before Running rubocop suggests `1 offense auto-correctable`. ```console % rubocop (snip) Inspecting 1 file C Offenses: example.rb:3:6: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. puts "hello" ^^^^^^^ 1 file inspected, 1 offense detected, 1 offense auto-correctable ``` Running `rubocop -a` suggests `1 more offense can be corrected with rubocop -A` next. ```console % rubocop -a (snip) Inspecting 1 file C Offenses: example.rb:3:6: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. puts "hello" ^^^^^^^ 1 file inspected, 1 offense detected, 1 more offense can be corrected with `rubocop -A` ``` Running `rubocop -A` does not auto-correct it. ```console % rubocop -A (snip) Inspecting 1 file C Offenses: example.rb:3:6: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. puts "hello" ^^^^^^^ 1 file inspected, 1 offense detected, 1 offense auto-correctable ``` There is no change in the code. ```console % cat example.rb # frozen_string_literal: true puts "hello" ``` User cannnot get the suggested behavior. ## After RuboCop does not suggest auto-correction if `AutoCorrect: false` is configured. ```console % rubocop (snip) Inspecting 1 file C Offenses: example.rb:3:6: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols. puts "hello" ^^^^^^^ 1 file inspected, 1 offense detected ```
- Loading branch information