We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Using gsub instead of delete for integers expressed as unicode characters should trigger this offense
gsub
delete
No offense is registered
str.gsub(8203.chr('UTF-8'),'') # should register offense and suggest use of delete
1.56.4 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux] - rubocop-capybara 2.18.0 - rubocop-minitest 0.31.1 - rubocop-performance 1.19.1 - rubocop-rake 0.6.0 - rubocop-sequel 0.3.4
There may also be unicode character substitution edge cases in the gsub vs. tr version of this cop too.
tr
The text was updated successfully, but these errors were encountered:
FWIW it is possible to match the two forms of integer coercion to an encoded character string using Integer#chr with a mere 103 regexps.
Integer#chr
str = '55_295.chr(Encoding::UTF-8)' str1 = "0.chr('ASCII-8BIT')" int_to_char_encoding_regexps = Encoding.list.map { |enc| /\d{0,2}_?\d{1,3}\.chr\((Encoding::)?'?#{Regexp.quote(enc.to_s)}'?\)/ } puts int_to_char_encoding_regexps.any? { |r| r.match? str } # => true puts int_to_char_encoding_regexps.any? { |r| r.match? str1 } # => true
I'm sure there's a more elegant way.
Sorry, something went wrong.
No branches or pull requests
Expected behavior
Using
gsub
instead ofdelete
for integers expressed as unicode characters should trigger this offenseActual behavior
No offense is registered
Steps to reproduce the problem
RuboCop version
There may also be unicode character substitution edge cases in the
gsub
vs.tr
version of this cop too.The text was updated successfully, but these errors were encountered: