-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PercentLiteralDelimiters incorrectly automatically modifies escaped percent literal delimiter #4363
Labels
Comments
11 tasks
koic
added a commit
to koic/rubocop
that referenced
this issue
Nov 11, 2017
…ters` cop Fixes rubocop#4363. Percent notation targeted by Issue # 4363 are `%w` and `%i`. `%W` and `%I` are not targets. ## %w / %W The meaning changes. ```ruby > %w(\() # => ["("] > %w[\(] # => ["\\("] ``` The meaning does not change. ```ruby > %W(\() # => ["("] > %W[\(] # => ["("] ``` ## %i / %I The meaning changes. ```ruby > %i(\() # => [:"("] > %i[\(] # => [:"\\("] ``` The meaning does not change ```ruby > %I(\() # => [:"("] > %I[\(] # => [:"("] ``` Also, if we use open delimiter and closing delimiter like `(...)`, we need to target both of them. ```ruby > %w(\() # => ["("] > %w[\(] # => ["\\("] > %w(\)) # => [")"] > %w[\)] # => ["\\)"] ``` There are 4 cases of `%w(...)`, `%w[...]`, `%w{...}`, and `%w<...>`. This commit changes so that it will not be offense if the same character as a percent notation delimiter is used for elements of an array.
bbatsov
pushed a commit
that referenced
this issue
Nov 11, 2017
…ters` cop (#5020) Fixes #4363. Percent notation targeted by Issue # 4363 are `%w` and `%i`. `%W` and `%I` are not targets. ## %w / %W The meaning changes. ```ruby > %w(\() # => ["("] > %w[\(] # => ["\\("] ``` The meaning does not change. ```ruby > %W(\() # => ["("] > %W[\(] # => ["("] ``` ## %i / %I The meaning changes. ```ruby > %i(\() # => [:"("] > %i[\(] # => [:"\\("] ``` The meaning does not change ```ruby > %I(\() # => [:"("] > %I[\(] # => [:"("] ``` Also, if we use open delimiter and closing delimiter like `(...)`, we need to target both of them. ```ruby > %w(\() # => ["("] > %w[\(] # => ["\\("] > %w(\)) # => [")"] > %w[\)] # => ["\\)"] ``` There are 4 cases of `%w(...)`, `%w[...]`, `%w{...}`, and `%w<...>`. This commit changes so that it will not be offense if the same character as a percent notation delimiter is used for elements of an array.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rubocop is correcting
to
but these are not the same thing
Expected behavior
Rubocop should not create the change, put issue a warning if the existing or target delimiters are contained within the array
Actual behavior
Steps to reproduce the problem
Add
to a file, and run rubocop on that file.
Additionally, this is in our
.rubocop.yml
fileRuboCop version
The text was updated successfully, but these errors were encountered: