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
no change
diff --git a/example.rb b/example.rb index 76f186f..d0847bb 100644 --- a/example.rb +++ b/example.rb @@ -7,7 +7,7 @@ class TestSample < Test::Unit::TestCase target = "This\nis\r\nReds." expected = 'This|is|Reds.' assert do - target.gsub(/\R/, '|') == expected + target.tr('R', '|') == expected end end end
example.rb
# frozen_string_literal: true require 'test/unit' # comment class TestSample < Test::Unit::TestCase test 'replace' do target = "This\nis\r\nReds." expected = 'This|is|Reds.' assert do target.gsub(/\R/, '|') == expected end end end
$ bundle exec ruby example.rb Loaded suite example Started . Finished in 0.00045 seconds. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2222.22 tests/s, 2222.22 assertions/s
$ bundle exec rubocop -a example.rb Inspecting 1 file C Offenses: example.rb:10:14: C: [Corrected] Use tr instead of gsub. target.gsub(/\R/, '|') == expected ^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected, 1 offense corrected
then
# frozen_string_literal: true require 'test/unit' # comment class TestSample < Test::Unit::TestCase test 'replace' do target = "This\nis\r\nReds." expected = 'This|is|Reds.' assert do target.tr('R', '|') == expected end end end
$ bundle exec ruby example.rb Loaded suite example Started F ================================================================================================================================================================================== Failure: target.tr('R', '|') == expected | | | | | | | "This|is|Reds." | | false | "This\nis\r\n|eds." "This\nis\r\nReds." test: replace(TestSample) /Users/murahashi.kenichi/temp/foog/vendor/bundle/ruby/2.3.0/gems/power_assert-0.2.6/lib/power_assert.rb:36:in `start' example.rb:9:in `block in <class:TestSample>' 6: test 'replace' do 7: target = "This\nis\r\nReds." 8: expected = 'This|is|Reds.' => 9: assert do 10: target.tr('R', '|') == expected 11: end 12: end ================================================================================================================================================================================== Finished in 0.008325 seconds. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 0% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 120.12 tests/s, 120.12 assertions/s
Include the output of rubocop -V:
rubocop -V
$ bundle exec rubocop -V 0.41.1 (using Parser 2.3.1.2, running on ruby 2.3.1 x86_64-darwin15)
.rubocop.yml
AllCops: TargetRubyVersion: 2.3
Gemfile
source "https://rubygems.org" gem "rubocop" gem "test-unit"
The text was updated successfully, but these errors were encountered:
[Fix rubocop#3272] Add escape character missing to LITERAL_REGEX
7eb0919
6a1fc93
[Fix rubocop#3272] Add escape character missing to LITERAL_REGEX (rub…
0823cec
…ocop#3275)
No branches or pull requests
Expected behavior
no change
Actual behavior
Steps to reproduce the problem
example.rb
then
example.rb
RuboCop version
Include the output of
rubocop -V
:Additional Info
.rubocop.yml
Gemfile
The text was updated successfully, but these errors were encountered: