-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an incorrect autocorrect for
Style/SpecialGlobalVars
This PR fixes the following incorrect autocorrect for `Style/SpecialGlobalVars` when global variable as Perl name is used multiple times. Example: ```ruby % cat example.rb $*[0] $*[1] % bundle exec rubocop --only Style/SpecialGlobalVars -A Inspecting 3 files .C. Offenses: example.rb:1:1: C: [Corrected] Style/SpecialGlobalVars: Prefer $ARGV from the stdlib 'English' module (don't forget to require it) or ARGV over $*. $*[0] ^^ example.rb:2:1: C: [Corrected] Style/SpecialGlobalVars: Prefer $ARGV from the stdlib 'English' module (don't forget to require it) or ARGV over $*. $*[1] ^^ 3 files inspected, 2 offenses detected, 2 offenses corrected ``` This auto-correction will add `require 'English'` twice: ```ruby % cat example.rb require 'English' require 'English' $ARGV[0] $ARGV[1] ``` This PR ensures that `require 'English'` is added only once: ```ruby % cat example.rb require 'English' $ARGV[0] $ARGV[1] ```
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog/fix_an_incorrect_autocorrect_for_style_special_global_vars.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#10541](https://github.com/rubocop/rubocop/pull/10541): Fix an incorrect autocorrect for `Style/SpecialGlobalVars` when global variable as Perl name is used multiple times. ([@koic][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters