diff --git a/Gemfile b/Gemfile index 1c3e4a8bd9f..099d5086b76 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ gem 'rake', '~> 13.0' gem 'rspec', '~> 3.7' gem 'rubocop-performance', '~> 1.11.0' gem 'rubocop-rake', '~> 0.6.0' -gem 'rubocop-rspec', '~> 2.3.0' +gem 'rubocop-rspec', '~> 2.5.0' # Workaround for cc-test-reporter with SimpleCov 0.18. # Stop upgrading SimpleCov until the following issue will be resolved. # https://github.com/codeclimate/test-reporter/issues/418 diff --git a/spec/rubocop/cli/auto_gen_config_spec.rb b/spec/rubocop/cli/auto_gen_config_spec.rb index 18a2a1cefd6..0691669b41e 100644 --- a/spec/rubocop/cli/auto_gen_config_spec.rb +++ b/spec/rubocop/cli/auto_gen_config_spec.rb @@ -200,7 +200,7 @@ def f end end - context 'when .rubocop.yml has Layout/LineLength disabled ' do + context 'when .rubocop.yml has Layout/LineLength disabled' do let(:line_length_max) { 90 } let(:line_length_enabled) { false } diff --git a/spec/rubocop/config_loader_spec.rb b/spec/rubocop/config_loader_spec.rb index 87cf5ad9c17..30c2044d938 100644 --- a/spec/rubocop/config_loader_spec.rb +++ b/spec/rubocop/config_loader_spec.rb @@ -1462,7 +1462,7 @@ def self.inject! ) end - it 'loads configuration properly when it includes non-ascii characters ' do + it 'loads configuration properly when it includes non-ascii characters' do create_file(configuration_path, <<~YAML) # All these cops of mine are ❤ Style/Encoding: diff --git a/spec/rubocop/cop/internal_affairs/redundant_message_argument_spec.rb b/spec/rubocop/cop/internal_affairs/redundant_message_argument_spec.rb index 5ce2749d010..6f0a0ce8e4f 100644 --- a/spec/rubocop/cop/internal_affairs/redundant_message_argument_spec.rb +++ b/spec/rubocop/cop/internal_affairs/redundant_message_argument_spec.rb @@ -75,7 +75,7 @@ end end - it 'does not register an offense when `#message` with another node is passed' do + it 'does not register an offense when `#message` with another node is passed' do expect_no_offenses(<<~RUBY, 'example_cop.rb') add_offense(node, message: message(other_node)) RUBY diff --git a/spec/rubocop/cop/layout/heredoc_argument_closing_parenthesis_spec.rb b/spec/rubocop/cop/layout/heredoc_argument_closing_parenthesis_spec.rb index d113cf194c1..ccaafa90969 100644 --- a/spec/rubocop/cop/layout/heredoc_argument_closing_parenthesis_spec.rb +++ b/spec/rubocop/cop/layout/heredoc_argument_closing_parenthesis_spec.rb @@ -298,7 +298,7 @@ end context 'double incorrect case' do - it 'detects ' do + it 'detects' do expect_offense(<<~RUBY) foo(<<-SQL, <<-NOSQL foo diff --git a/spec/rubocop/cop/layout/line_length_spec.rb b/spec/rubocop/cop/layout/line_length_spec.rb index d2c7dc8a1f9..05183650185 100644 --- a/spec/rubocop/cop/layout/line_length_spec.rb +++ b/spec/rubocop/cop/layout/line_length_spec.rb @@ -1087,7 +1087,7 @@ def baz(bar) end end - context 'semicolons inside string literal' do + context 'semicolons inside string literal' do it 'adds offense and autocorrects elsewhere' do expect_offense(<<~RUBY) "00000000000000000;0000000000000000000'000000;00000'0000;0000;000" diff --git a/spec/rubocop/cop/layout/multiline_method_call_brace_layout_spec.rb b/spec/rubocop/cop/layout/multiline_method_call_brace_layout_spec.rb index 733b71d9284..e53c2659797 100644 --- a/spec/rubocop/cop/layout/multiline_method_call_brace_layout_spec.rb +++ b/spec/rubocop/cop/layout/multiline_method_call_brace_layout_spec.rb @@ -22,7 +22,7 @@ expect_no_offenses('puts()') end - it 'ignores calls with a multiline empty brace ' do + it 'ignores calls with a multiline empty brace' do expect_no_offenses(<<~RUBY) puts( ) diff --git a/spec/rubocop/cop/lint/raise_exception_spec.rb b/spec/rubocop/cop/lint/raise_exception_spec.rb index c808409cca2..b09f7d02721 100644 --- a/spec/rubocop/cop/lint/raise_exception_spec.rb +++ b/spec/rubocop/cop/lint/raise_exception_spec.rb @@ -69,7 +69,7 @@ RUBY end - it 'registers an offense and corrects for `raise` with `Exception.new(args*)` ' do + it 'registers an offense and corrects for `raise` with `Exception.new(args*)`' do expect_offense(<<~RUBY) raise Exception.new('arg1', 'arg2') ^^^^^^^^^ Use `StandardError` over `Exception`. diff --git a/spec/rubocop/cop/lint/shadowed_exception_spec.rb b/spec/rubocop/cop/lint/shadowed_exception_spec.rb index 9dbcc760fb7..d41ba0fe995 100644 --- a/spec/rubocop/cop/lint/shadowed_exception_spec.rb +++ b/spec/rubocop/cop/lint/shadowed_exception_spec.rb @@ -85,7 +85,7 @@ def foo RUBY end - it 'registers an offense rescuing exceptions that are ancestors of each other ' do + it 'registers an offense rescuing exceptions that are ancestors of each other' do expect_offense(<<~RUBY) def something diff --git a/spec/rubocop/cop/lint/useless_access_modifier_spec.rb b/spec/rubocop/cop/lint/useless_access_modifier_spec.rb index 29ebd1e7a2b..ef63c0d9393 100644 --- a/spec/rubocop/cop/lint/useless_access_modifier_spec.rb +++ b/spec/rubocop/cop/lint/useless_access_modifier_spec.rb @@ -815,8 +815,7 @@ def method1 end context 'inside a class' do - it 'registers an offense when a modifier is ouside the block and a ' \ - 'method is defined only inside the block' do + it 'registers an offense when a modifier is ouside the block and a method is defined only inside the block' do expect_offense(<<~RUBY, modifier: modifier) class A %{modifier} @@ -829,8 +828,7 @@ def method1 RUBY end - it 'registers two offenses when a modifier is inside and outside the ' \ - ' block and no method is defined' do + it 'registers two offenses when a modifier is inside and outside the block and no method is defined' do expect_offense(<<~RUBY, modifier: modifier) class A %{modifier} @@ -901,8 +899,7 @@ def method1 RUBY end - it 'registers two offenses when a modifier is inside and outside the ' \ - ' and no method is defined' do + it 'registers two offenses when a modifier is inside and outside the and no method is defined' do expect_offense(<<~RUBY, modifier: modifier) class A %{modifier} diff --git a/spec/rubocop/cop/lint/useless_assignment_spec.rb b/spec/rubocop/cop/lint/useless_assignment_spec.rb index 3cc5128cc58..41b25298c98 100644 --- a/spec/rubocop/cop/lint/useless_assignment_spec.rb +++ b/spec/rubocop/cop/lint/useless_assignment_spec.rb @@ -569,8 +569,8 @@ def some_method(flag) end end - context 'when a variable is reassigned and unreferenced in a if branch ' \ - 'while the variable is referenced in the paired else branch ' do + context 'when a variable is reassigned and unreferenced in a if branch' \ + ' while the variable is referenced in the paired else branch' do it 'registers an offense for the reassignment in the if branch' do expect_offense(<<~RUBY) def some_method(flag) diff --git a/spec/rubocop/cop/naming/method_name_spec.rb b/spec/rubocop/cop/naming/method_name_spec.rb index 40472c2966d..85317886b34 100644 --- a/spec/rubocop/cop/naming/method_name_spec.rb +++ b/spec/rubocop/cop/naming/method_name_spec.rb @@ -150,7 +150,7 @@ def base.Start(aws_env, *args) RUBY end - it 'does not register an offense for camel case method name matching `IgnoredPatterns`' do + it 'does not register an offense for camel case method name matching `IgnoredPatterns`' do expect_no_offenses(<<~RUBY) def onSelectionBulkChange(arg) end @@ -165,7 +165,7 @@ def onSelectionBulkChange(arg) RUBY end - it 'does not register an offense for snake case method name matching `IgnoredPatterns`' do + it 'does not register an offense for snake case method name matching `IgnoredPatterns`' do expect_no_offenses(<<~RUBY) def on_selection_cleared(arg) end diff --git a/spec/rubocop/cop/style/conditional_assignment_assign_to_condition_spec.rb b/spec/rubocop/cop/style/conditional_assignment_assign_to_condition_spec.rb index 48a4d4fb7a4..a7969b1a949 100644 --- a/spec/rubocop/cop/style/conditional_assignment_assign_to_condition_spec.rb +++ b/spec/rubocop/cop/style/conditional_assignment_assign_to_condition_spec.rb @@ -704,7 +704,7 @@ RUBY end - it "registers an offense for assignment using #{assignment} in case when" do + it "registers an offense for assignment using #{assignment} in case when" do expect_offense(<<~RUBY) case foo ^^^^^^^^ Use the return of the conditional for variable assignment and comparison. diff --git a/spec/rubocop/cop/style/empty_literal_spec.rb b/spec/rubocop/cop/style/empty_literal_spec.rb index f784a4bf1ac..28e8db77bac 100644 --- a/spec/rubocop/cop/style/empty_literal_spec.rb +++ b/spec/rubocop/cop/style/empty_literal_spec.rb @@ -123,7 +123,7 @@ end end - it 'auto-corrects Hash.new in block ' do + it 'auto-corrects Hash.new in block' do expect_offense(<<~RUBY) puts { Hash.new } ^^^^^^^^ Use hash literal `{}` instead of `Hash.new`. diff --git a/spec/rubocop/cop/style/eval_with_location_spec.rb b/spec/rubocop/cop/style/eval_with_location_spec.rb index 4cf976372fd..3aef4080853 100644 --- a/spec/rubocop/cop/style/eval_with_location_spec.rb +++ b/spec/rubocop/cop/style/eval_with_location_spec.rb @@ -96,7 +96,7 @@ RUBY end - it 'registers an offense when using `#eval` with a string on a new line ' do + it 'registers an offense when using `#eval` with a string on a new line' do expect_offense(<<~RUBY) eval('puts 42', binding, diff --git a/spec/rubocop/cop/style/hash_conversion_spec.rb b/spec/rubocop/cop/style/hash_conversion_spec.rb index ec790450c16..cc773d69b96 100644 --- a/spec/rubocop/cop/style/hash_conversion_spec.rb +++ b/spec/rubocop/cop/style/hash_conversion_spec.rb @@ -67,7 +67,7 @@ RUBY end - it 'registers and corrects an offense when using multi-argument `Hash[]` as a method argument' do + it 'registers and corrects an offense when using multi-argument `Hash[]` as a method argument' do expect_offense(<<~RUBY) do_something Hash[a, b, c, d], arg ^^^^^^^^^^^^^^^^ Prefer literal hash to Hash[arg1, arg2, ...]. diff --git a/spec/rubocop/cop/style/inverse_methods_spec.rb b/spec/rubocop/cop/style/inverse_methods_spec.rb index 3e6ed581e26..25d8f8f8215 100644 --- a/spec/rubocop/cop/style/inverse_methods_spec.rb +++ b/spec/rubocop/cop/style/inverse_methods_spec.rb @@ -299,7 +299,7 @@ def test_method RUBY end - it 'corrects an inverted method call when using `BasicObject# !`' do + it 'corrects an inverted method call when using `BasicObject#!` with spaces before the method call' do expect_offense(<<~RUBY, method: method) foo.%{method} { |e| e.bar?. ! } ^^^^^{method}^^^^^^^^^^^^^^^^^^^ Use `#{inverse}` instead of inverting `#{method}`. diff --git a/spec/rubocop/cop/style/method_call_without_args_parentheses_spec.rb b/spec/rubocop/cop/style/method_call_without_args_parentheses_spec.rb index d1dec6873b1..4b62f84b1de 100644 --- a/spec/rubocop/cop/style/method_call_without_args_parentheses_spec.rb +++ b/spec/rubocop/cop/style/method_call_without_args_parentheses_spec.rb @@ -48,7 +48,7 @@ end context 'assignment to a variable with the same name' do - it 'accepts parens in local variable assignment ' do + it 'accepts parens in local variable assignment' do expect_no_offenses('test = test()') end diff --git a/spec/rubocop/cop/style/redundant_freeze_spec.rb b/spec/rubocop/cop/style/redundant_freeze_spec.rb index 2ffc476a07f..07110f036af 100644 --- a/spec/rubocop/cop/style/redundant_freeze_spec.rb +++ b/spec/rubocop/cop/style/redundant_freeze_spec.rb @@ -45,7 +45,7 @@ it_behaves_like 'mutable objects', "ENV['foo']" it_behaves_like 'mutable objects', "::ENV['foo']" - it 'allows .freeze on method call' do + it 'allows .freeze on method call' do expect_no_offenses('TOP_TEST = Something.new.freeze') end diff --git a/spec/rubocop/cop/style/redundant_parentheses_spec.rb b/spec/rubocop/cop/style/redundant_parentheses_spec.rb index dc7f613acb9..be3da5b7408 100644 --- a/spec/rubocop/cop/style/redundant_parentheses_spec.rb +++ b/spec/rubocop/cop/style/redundant_parentheses_spec.rb @@ -381,13 +381,13 @@ def x end context 'when the first argument in a method call begins with a hash literal' do - it 'accepts parentheses if the argument list is not parenthesized ' do + it 'accepts parentheses if the argument list is not parenthesized' do expect_no_offenses('x ({ y: 1 }), z') expect_no_offenses('x ({ y: 1 }.merge({ y: 2 })), z') expect_no_offenses('x ({ y: 1 }.merge({ y: 2 }).merge({ y: 3 })), z') end - it 'registers an offense if the argument list is parenthesized ' do + it 'registers an offense if the argument list is parenthesized' do expect_offense(<<~RUBY) x(({ y: 1 }), z) ^^^^^^^^^^ Don't use parentheses around a literal. diff --git a/spec/rubocop/cop/style/safe_navigation_spec.rb b/spec/rubocop/cop/style/safe_navigation_spec.rb index a69e10d4f6e..27806025af8 100644 --- a/spec/rubocop/cop/style/safe_navigation_spec.rb +++ b/spec/rubocop/cop/style/safe_navigation_spec.rb @@ -917,8 +917,7 @@ def foobar RUBY end - it 'registers an offense for an object check followed by ' \ - 'a method calls that nil responds to ' do + it 'registers an offense for an object check followed by a method calls that nil responds to' do expect_offense(<<~RUBY, variable: variable) %{variable} && %{variable}.to_i ^{variable}^^^^^{variable}^^^^^ Use safe navigation (`&.`) instead [...] diff --git a/spec/rubocop/cop/style/sole_nested_conditional_spec.rb b/spec/rubocop/cop/style/sole_nested_conditional_spec.rb index ea7caa360fa..553ca55e9af 100644 --- a/spec/rubocop/cop/style/sole_nested_conditional_spec.rb +++ b/spec/rubocop/cop/style/sole_nested_conditional_spec.rb @@ -216,8 +216,7 @@ def foo RUBY end - it 'registers an offense and corrects when using `||` in the outer condition' \ - 'and nested modifier condition ' do + it 'registers an offense and corrects when using `||` in the outer condition and nested modifier condition' do expect_offense(<<~RUBY) if foo || bar do_something if baz || qux @@ -233,7 +232,7 @@ def foo end it 'registers an offense and corrects when using `unless` and `||` and parens in the outer condition' \ - 'and nested modifier condition ' do + ' and nested modifier condition' do expect_offense(<<~RUBY) unless (foo || bar) do_something if baz @@ -249,7 +248,7 @@ def foo end it 'registers an offense and corrects when using `unless` and `||` without parens in the outer condition' \ - 'and nested modifier condition ' do + ' and nested modifier condition' do expect_offense(<<~RUBY) unless foo || bar do_something if baz diff --git a/spec/rubocop/cop/style/trailing_underscore_variable_spec.rb b/spec/rubocop/cop/style/trailing_underscore_variable_spec.rb index e08d16b8f13..5eb6980696a 100644 --- a/spec/rubocop/cop/style/trailing_underscore_variable_spec.rb +++ b/spec/rubocop/cop/style/trailing_underscore_variable_spec.rb @@ -13,8 +13,7 @@ RUBY end - it 'registers an offense when multiple underscores are used '\ - 'as the last variables of parallel assignment ' do + it 'registers an offense when multiple underscores are used as the last variables of parallel assignment' do expect_offense(<<~RUBY) a, _, _ = foo() ^^^^^ Do not use trailing `_`s in parallel assignment. Prefer `a, = foo()`.