You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a string where I am trying to replace some unicode chars and rubocop is saying that it's a redundant single-element character class when I don't believe it is.
In this example I am going to try to replace all a and b (unicode 0061 0062) with the letter F
s="aaabbbccc"s.gsub(/[\u{0061 0062}]/,"F")# this correctly outputs "FFFFFFccc" which is correct.
Rubocop however suggests I should remove the square brackets with :
Style/RedundantRegexpCharacterClass: Redundant single-element character class, `[\u{0061 0062}]` can be replaced with `\u{0061 0062}`
However, if you remove the braces you get an incorrect value
s="aaabbbccc"s.gsub(/\u{0061 0062}/,"F")# this incorrectly outputs "aaFbbccc" which is incorrect.
Expected behavior
/[\u{0061 0062}]/
should not suggest Style/RedundantRegexpCharacterClass
Actual behavior
/[\u{0061 0062}]/
does suggest Style/RedundantRegexpCharacterClass
Steps to reproduce the problem
create the line s = /[\u{0061 0062}]/ in a ruby file, expect no violations.
RuboCop version
1.27.0
The text was updated successfully, but these errors were encountered:
…aracterClass`
Fixesrubocop#10530.
This PR fixes a false positive for `Style/RedundantRegexpCharacterClass`
when using regexp character class with a character class containing
multiple unicode code-points.
…Class`
Fixes#10530.
This PR fixes a false positive for `Style/RedundantRegexpCharacterClass`
when using regexp character class with a character class containing
multiple unicode code-points.
I have a string where I am trying to replace some unicode chars and rubocop is saying that it's a redundant single-element character class when I don't believe it is.
In this example I am going to try to replace all
a
andb
(unicode 0061 0062) with the letterF
Rubocop however suggests I should remove the square brackets with :
However, if you remove the braces you get an incorrect value
Expected behavior
/[\u{0061 0062}]/
should not suggest Style/RedundantRegexpCharacterClass
Actual behavior
/[\u{0061 0062}]/
does suggest Style/RedundantRegexpCharacterClass
Steps to reproduce the problem
s = /[\u{0061 0062}]/
in a ruby file, expect no violations.RuboCop version
1.27.0
The text was updated successfully, but these errors were encountered: