From 2b42f1e55b802661d8c8377a739a01ede8dc0c8e Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Wed, 13 May 2020 13:29:45 -0400 Subject: [PATCH 1/2] Refactor `config` shared context. Simplify some specs. --- lib/rubocop/rspec/shared_contexts.rb | 70 +++++++++++--- spec/rubocop/cop/alignment_corrector_spec.rb | 4 +- spec/rubocop/cop/cop_spec.rb | 94 +++++++++---------- .../redundant_cop_disable_directive_spec.rb | 18 +--- spec/rubocop/cop/style/guard_clause_spec.rb | 13 +-- .../formatter/clang_style_formatter_spec.rb | 30 +++--- 6 files changed, 123 insertions(+), 106 deletions(-) diff --git a/lib/rubocop/rspec/shared_contexts.rb b/lib/rubocop/rspec/shared_contexts.rb index 31a182482f6..1cb55725557 100644 --- a/lib/rubocop/rspec/shared_contexts.rb +++ b/lib/rubocop/rspec/shared_contexts.rb @@ -38,26 +38,66 @@ end end -# `cop_config` must be declared with #let. -RSpec.shared_context 'config', :config do - let(:config) do - # Module#< - raise '`config` must be used in `describe SomeCopClass do .. end`' unless described_class < RuboCop::Cop::Cop - - hash = { 'AllCops' => { 'TargetRubyVersion' => ruby_version } } - hash['AllCops']['TargetRailsVersion'] = rails_version if rails_version - if respond_to?(:cop_config) - cop_name = described_class.cop_name - hash[cop_name] = RuboCop::ConfigLoader - .default_configuration[cop_name] - .merge('Enabled' => true) # in case it is 'pending' - .merge(cop_config) +# This context assumes nothing and defines `cop`, among others. +RSpec.shared_context 'config', :config do # rubocop:disable Metrics/BlockLength + ### Meant to be overriden at will + + let(:source) { 'code = {some: :ruby}' } + + let(:cop_class) do + if described_class.is_a?(Class) && described_class < RuboCop::Cop::Cop + described_class + else + RuboCop::Cop::Cop end + end + + let(:cop_config) { {} } + + let(:other_cops) { {} } + + let(:cop_options) { {} } + + ### Utilities + + def source_range(range, buffer: source_buffer) + Parser::Source::Range.new(buffer, range.begin, + range.exclude_end? ? range.end : range.end + 1) + end - hash = other_cops.merge hash if respond_to?(:other_cops) + ### Usefull intermediary steps (less likely to be overriden) + + let(:processed_source) { parse_source(source, 'test') } + + let(:source_buffer) { processed_source.buffer } + + let(:all_cops_config) do + rails = { 'TargetRubyVersion' => ruby_version } + rails['TargetRailsVersion'] = rails_version if rails_version + rails + end + + let(:cur_cop_config) do + RuboCop::ConfigLoader + .default_configuration.for_cop(cop_class) + .merge({ + 'Enabled' => true, # in case it is 'pending' + 'AutoCorrect' => true # in case defaults set it to false + }) + .merge(cop_config) + end + + let(:config) do + hash = { 'AllCops' => all_cops_config, + cop_class.cop_name => cur_cop_config }.merge!(other_cops) RuboCop::Config.new(hash, "#{Dir.pwd}/.rubocop.yml") end + + let(:cop) do + cop_class.new(config, cop_options) + .tap { |cop| cop.processed_source = processed_source } + end end RSpec.shared_context 'mock console output' do diff --git a/spec/rubocop/cop/alignment_corrector_spec.rb b/spec/rubocop/cop/alignment_corrector_spec.rb index 695df4ac6d4..2b655f2b7bf 100644 --- a/spec/rubocop/cop/alignment_corrector_spec.rb +++ b/spec/rubocop/cop/alignment_corrector_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.describe RuboCop::Cop::AlignmentCorrector do - let(:cop) { RuboCop::Cop::Test::AlignmentDirective.new } +RSpec.describe RuboCop::Cop::AlignmentCorrector, :config do + let(:cop_class) { RuboCop::Cop::Test::AlignmentDirective } describe '#correct' do context 'simple indentation' do diff --git a/spec/rubocop/cop/cop_spec.rb b/spec/rubocop/cop/cop_spec.rb index 33ef71f145d..4c23369ef09 100644 --- a/spec/rubocop/cop/cop_spec.rb +++ b/spec/rubocop/cop/cop_spec.rb @@ -1,12 +1,8 @@ # frozen_string_literal: true -RSpec.describe RuboCop::Cop::Cop do - subject(:cop) { described_class.new } - +RSpec.describe RuboCop::Cop::Cop, :config do let(:location) do - source_buffer = Parser::Source::Buffer.new('test', 1) - source_buffer.source = "a\n" - Parser::Source::Range.new(source_buffer, 0, 1) + source_range(0...1) end it 'initially has 0 offenses' do @@ -90,32 +86,41 @@ .to output(/Warning: Invalid severity 'superbad'./).to_stderr end - it 'will set offense as disabled if ignore_disable_comments is false' do - comment_config = instance_double(RuboCop::CommentConfig, - cop_enabled_at_line?: false) - processed_source = instance_double(RuboCop::ProcessedSource, - comment_config: comment_config) - cop.processed_source = processed_source - cop.instance_variable_set(:@options, ignore_disable_comments: false) - cop.add_offense(nil, location: location, message: 'message') - expect(cop.offenses.first.status).to eq :disabled - end + context 'when disabled by a comment' do + subject(:offense_status) do + cop.add_offense(nil, location: location, message: 'message') + cop.offenses.first.status + end - it 'will not set offense as disabled if ignore_disable_comments is true' do - comment_config = instance_double(RuboCop::CommentConfig, - cop_enabled_at_line?: false) - processed_source = instance_double(RuboCop::ProcessedSource, - comment_config: comment_config) - cop.processed_source = processed_source - cop.instance_variable_set(:@options, ignore_disable_comments: true) - cop.add_offense(nil, location: location, message: 'message') - expect(cop.offenses.first.status).not_to eq :disabled + before do + allow(processed_source.comment_config).to receive(:cop_enabled_at_line?) + .and_return(false) + end + + context 'ignore_disable_comments is false' do + let(:cop_options) { { ignore_disable_comments: false } } + + it 'will set offense as disabled' do + expect(offense_status).to eq :disabled + end + end + + context 'ignore_disable_comments is true' do + let(:cop_options) { { ignore_disable_comments: true } } + + it 'will not set offense as disabled' do + expect(offense_status).not_to eq :disabled + end + end end - it 'registers offense with its name' do - cop = RuboCop::Cop::Style::For.new - cop.add_offense(nil, location: location, message: 'message') - expect(cop.offenses.first.cop_name).to eq('Style/For') + describe 'for a cop with a name' do + let(:cop_class) { RuboCop::Cop::Style::For } + + it 'registers offense with its name' do + cop.add_offense(nil, location: location, message: 'message') + expect(cop.offenses.first.cop_name).to eq('Style/For') + end end describe 'setting of Offense#corrected attribute' do @@ -161,7 +166,7 @@ end context 'when cop supports autocorrection' do - let(:cop) { RuboCop::Cop::Style::Alias.new } + let(:cop_class) { RuboCop::Cop::Style::Alias } context 'when offense was corrected' do before do @@ -201,24 +206,22 @@ end context 'with no submodule' do - subject(:cop) { described_class } - - it('has right name') { expect(cop.cop_name).to eq('Cop/Cop') } - it('has right department') { expect(cop.department).to eq(:Cop) } + it('has right name') { expect(cop_class.cop_name).to eq('Cop/Cop') } + it('has right department') { expect(cop_class.department).to eq(:Cop) } end context 'with style cops' do - subject(:cop) { RuboCop::Cop::Style::For } + let(:cop_class) { RuboCop::Cop::Style::For } - it('has right name') { expect(cop.cop_name).to eq('Style/For') } - it('has right department') { expect(cop.department).to eq(:Style) } + it('has right name') { expect(cop_class.cop_name).to eq('Style/For') } + it('has right department') { expect(cop_class.department).to eq(:Style) } end context 'with lint cops' do - subject(:cop) { RuboCop::Cop::Lint::Loop } + let(:cop_class) { RuboCop::Cop::Lint::Loop } - it('has right name') { expect(cop.cop_name).to eq('Lint/Loop') } - it('has right department') { expect(cop.department).to eq(:Lint) } + it('has right name') { expect(cop_class.cop_name).to eq('Lint/Loop') } + it('has right department') { expect(cop_class.department).to eq(:Lint) } end describe 'Registry' do @@ -262,8 +265,6 @@ subject { cop.autocorrect? } - let(:config) { RuboCop::Config.new({}) } - let(:cop) { described_class.new(config, options) } let(:support_autocorrect) { true } let(:disable_uncorrectable) { false } @@ -279,7 +280,7 @@ end context 'when the option is given' do - let(:options) { { auto_correct: true } } + let(:cop_options) { { auto_correct: true } } it { is_expected.to be(true) } @@ -296,9 +297,7 @@ end context 'when the cop is set to not autocorrect' do - let(:config) do - RuboCop::Config.new('Cop/Cop' => { 'AutoCorrect' => false }) - end + let(:cop_options) { { 'AutoCorrect' => false } } it { is_expected.to be(false) } end @@ -308,9 +307,6 @@ describe '#safe_autocorrect?' do subject { cop.safe_autocorrect? } - let(:config) { RuboCop::Config.new('Cop/Cop' => cop_config) } - let(:cop) { described_class.new(config) } - context 'when cop is declared unsafe' do let(:cop_config) { { 'Safe' => false } } diff --git a/spec/rubocop/cop/lint/redundant_cop_disable_directive_spec.rb b/spec/rubocop/cop/lint/redundant_cop_disable_directive_spec.rb index 66739fc4d4b..a8c4f4b28bc 100644 --- a/spec/rubocop/cop/lint/redundant_cop_disable_directive_spec.rb +++ b/spec/rubocop/cop/lint/redundant_cop_disable_directive_spec.rb @@ -1,16 +1,8 @@ # frozen_string_literal: true -RSpec.describe RuboCop::Cop::Lint::RedundantCopDisableDirective do +RSpec.describe RuboCop::Cop::Lint::RedundantCopDisableDirective, :config do describe '.check' do - let(:cop) do - cop = described_class.new - cop.instance_variable_get(:@options)[:auto_correct] = true - cop.processed_source = processed_source - cop - end - let(:processed_source) do - RuboCop::ProcessedSource.new(source, ruby_version) - end + let(:cop_options) { { auto_correct: true } } let(:comments) { processed_source.comments } let(:corrected_source) do RuboCop::Cop::Corrector @@ -246,9 +238,9 @@ 'Unnecessary disabling of `Lint/Debugger`.']) expect(cop.highlights).to eq(%w[ClassLength Debugger]) expect($stderr.string).to eq(<<~OUTPUT) - (string): Warning: no department given for MethodLength. - (string): Warning: no department given for ClassLength. - (string): Warning: no department given for Debugger. + test: Warning: no department given for MethodLength. + test: Warning: no department given for ClassLength. + test: Warning: no department given for Debugger. OUTPUT end end diff --git a/spec/rubocop/cop/style/guard_clause_spec.rb b/spec/rubocop/cop/style/guard_clause_spec.rb index fe763bdd8d9..45913ef4619 100644 --- a/spec/rubocop/cop/style/guard_clause_spec.rb +++ b/spec/rubocop/cop/style/guard_clause_spec.rb @@ -1,18 +1,15 @@ # frozen_string_literal: true -RSpec.describe RuboCop::Cop::Style::GuardClause do - let(:cop) { described_class.new(config) } - let(:config) do - RuboCop::Config.new( +RSpec.describe RuboCop::Cop::Style::GuardClause, :config do + let(:other_cops) do + { 'Layout/LineLength' => { 'Enabled' => line_length_enabled, 'Max' => 80 - }, - 'Style/GuardClause' => cop_config - ) + } + } end let(:line_length_enabled) { true } - let(:cop_config) { {} } shared_examples 'reports offense' do |body| it 'reports an offense if method body is if / unless without else' do diff --git a/spec/rubocop/formatter/clang_style_formatter_spec.rb b/spec/rubocop/formatter/clang_style_formatter_spec.rb index 063f4885aa3..c99ddadec34 100644 --- a/spec/rubocop/formatter/clang_style_formatter_spec.rb +++ b/spec/rubocop/formatter/clang_style_formatter_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe RuboCop::Formatter::ClangStyleFormatter do +RSpec.describe RuboCop::Formatter::ClangStyleFormatter, :config do subject(:formatter) { described_class.new(output) } let(:output) { StringIO.new } @@ -13,16 +13,13 @@ 'This is a message.', 'CopName', status) end + let(:source) { ('aa'..'az').to_a.join($RS) } + let(:location) do - source_buffer = Parser::Source::Buffer.new('test', 1) - source_buffer.source = "a\n" - Parser::Source::Range.new(source_buffer, 0, 1) + source_range(0...1) end it 'displays text containing the offending source line' do - cop = RuboCop::Cop::Cop.new - source_buffer = Parser::Source::Buffer.new('test', 1) - source_buffer.source = ('aa'..'az').to_a.join($RS) cop.add_offense( nil, location: Parser::Source::Range.new(source_buffer, 0, 2), @@ -46,10 +43,9 @@ end context 'when the source line is blank' do + let(:source) { [' ', 'yaba'].join($RS) } + it 'does not display offending source line' do - cop = RuboCop::Cop::Cop.new - source_buffer = Parser::Source::Buffer.new('test', 1) - source_buffer.source = [' ', 'yaba'].join($RS) cop.add_offense( nil, location: Parser::Source::Range.new(source_buffer, 0, 2), @@ -72,21 +68,17 @@ end context 'when the offending source spans multiple lines' do - it 'displays the first line with ellipses' do - source = <<~RUBY + let(:source) do + <<~RUBY do_something([this, is, target]) RUBY + end - source_buffer = Parser::Source::Buffer.new('test', 1) - source_buffer.source = source - - location = Parser::Source::Range.new(source_buffer, - source.index('['), - source.index(']') + 1) + it 'displays the first line with ellipses' do + location = source_range(source.index('[')..source.index(']')) - cop = RuboCop::Cop::Cop.new cop.add_offense(nil, location: location, message: 'message 1') formatter.report_file('test', cop.offenses) From 67ed5a7f9ed26da2ca59928058e14f33bf7938fa Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Wed, 20 May 2020 17:18:57 -0400 Subject: [PATCH 2/2] Remove unneeded let for specs using :config shared environment --- spec/rubocop/cop/bundler/duplicated_gem_spec.rb | 2 -- spec/rubocop/cop/bundler/gem_comment_spec.rb | 2 -- spec/rubocop/cop/bundler/ordered_gems_spec.rb | 2 -- spec/rubocop/cop/gemspec/ordered_dependencies_spec.rb | 2 -- spec/rubocop/cop/gemspec/required_ruby_version_spec.rb | 2 -- spec/rubocop/cop/gemspec/ruby_version_globals_usage_spec.rb | 2 -- spec/rubocop/cop/layout/assignment_indentation_spec.rb | 2 -- spec/rubocop/cop/layout/block_alignment_spec.rb | 2 -- spec/rubocop/cop/layout/class_structure_spec.rb | 2 -- spec/rubocop/cop/layout/def_end_alignment_spec.rb | 2 -- spec/rubocop/cop/layout/dot_position_spec.rb | 2 -- spec/rubocop/cop/layout/empty_comment_spec.rb | 2 -- spec/rubocop/cop/layout/empty_line_between_defs_spec.rb | 2 -- .../cop/layout/empty_lines_around_access_modifier_spec.rb | 2 -- spec/rubocop/cop/layout/empty_lines_around_arguments_spec.rb | 2 -- spec/rubocop/cop/layout/empty_lines_around_block_body_spec.rb | 2 -- spec/rubocop/cop/layout/empty_lines_around_class_body_spec.rb | 2 -- spec/rubocop/cop/layout/empty_lines_around_module_body_spec.rb | 2 -- spec/rubocop/cop/layout/end_alignment_spec.rb | 2 -- spec/rubocop/cop/layout/end_of_line_spec.rb | 2 -- spec/rubocop/cop/layout/extra_spacing_spec.rb | 2 -- spec/rubocop/cop/layout/first_argument_indentation_spec.rb | 2 -- spec/rubocop/cop/layout/first_parameter_indentation_spec.rb | 2 -- spec/rubocop/cop/layout/hash_alignment_spec.rb | 2 -- spec/rubocop/cop/layout/heredoc_indentation_spec.rb | 2 -- spec/rubocop/cop/layout/indentation_consistency_spec.rb | 2 -- spec/rubocop/cop/layout/leading_comment_space_spec.rb | 2 -- spec/rubocop/cop/layout/leading_empty_lines_spec.rb | 2 -- spec/rubocop/cop/layout/line_length_spec.rb | 2 -- spec/rubocop/cop/layout/multiline_array_brace_layout_spec.rb | 2 -- spec/rubocop/cop/layout/multiline_assignment_layout_spec.rb | 2 -- spec/rubocop/cop/layout/multiline_hash_brace_layout_spec.rb | 2 -- .../cop/layout/multiline_method_call_brace_layout_spec.rb | 2 -- .../cop/layout/multiline_method_definition_brace_layout_spec.rb | 2 -- spec/rubocop/cop/layout/rescue_ensure_alignment_spec.rb | 2 -- spec/rubocop/cop/layout/space_around_block_parameters_spec.rb | 2 -- .../cop/layout/space_around_equals_in_parameter_default_spec.rb | 2 -- spec/rubocop/cop/layout/space_before_block_braces_spec.rb | 2 -- spec/rubocop/cop/layout/space_before_first_arg_spec.rb | 2 -- spec/rubocop/cop/layout/space_in_lambda_literal_spec.rb | 2 -- .../cop/layout/space_inside_array_literal_brackets_spec.rb | 2 -- .../rubocop/cop/layout/space_inside_hash_literal_braces_spec.rb | 2 -- spec/rubocop/cop/layout/space_inside_parens_spec.rb | 2 -- spec/rubocop/cop/layout/space_inside_reference_brackets_spec.rb | 2 -- .../cop/layout/space_inside_string_interpolation_spec.rb | 2 -- spec/rubocop/cop/layout/trailing_empty_lines_spec.rb | 2 -- spec/rubocop/cop/layout/trailing_whitespace_spec.rb | 2 -- spec/rubocop/cop/lint/assignment_in_condition_spec.rb | 2 -- spec/rubocop/cop/lint/boolean_symbol_spec.rb | 2 -- spec/rubocop/cop/lint/debugger_spec.rb | 2 -- spec/rubocop/cop/lint/empty_when_spec.rb | 2 -- spec/rubocop/cop/lint/erb_new_arguments_spec.rb | 2 -- spec/rubocop/cop/lint/inherit_exception_spec.rb | 2 -- spec/rubocop/cop/lint/missing_cop_enable_directive_spec.rb | 2 -- spec/rubocop/cop/lint/ordered_magic_comments_spec.rb | 2 -- spec/rubocop/cop/lint/raise_exception_spec.rb | 2 -- spec/rubocop/cop/lint/redundant_require_statement_spec.rb | 2 -- spec/rubocop/cop/lint/safe_navigation_chain_spec.rb | 2 -- spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb | 2 -- spec/rubocop/cop/lint/shadowed_argument_spec.rb | 2 -- spec/rubocop/cop/lint/suppressed_exception_spec.rb | 2 -- spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb | 2 -- spec/rubocop/cop/lint/unified_integer_spec.rb | 2 -- spec/rubocop/cop/lint/unused_block_argument_spec.rb | 2 -- spec/rubocop/cop/lint/unused_method_argument_spec.rb | 2 -- spec/rubocop/cop/metrics/abc_size_spec.rb | 2 -- spec/rubocop/cop/metrics/block_length_spec.rb | 2 -- spec/rubocop/cop/metrics/block_nesting_spec.rb | 2 -- spec/rubocop/cop/metrics/class_length_spec.rb | 2 -- spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb | 2 -- spec/rubocop/cop/metrics/method_length_spec.rb | 2 -- spec/rubocop/cop/metrics/module_length_spec.rb | 2 -- spec/rubocop/cop/metrics/parameter_lists_spec.rb | 2 -- spec/rubocop/cop/metrics/perceived_complexity_spec.rb | 2 -- spec/rubocop/cop/naming/block_parameter_name_spec.rb | 2 -- spec/rubocop/cop/naming/heredoc_delimiter_case_spec.rb | 2 -- spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb | 2 -- spec/rubocop/cop/naming/memoized_instance_variable_name_spec.rb | 2 -- spec/rubocop/cop/naming/method_name_spec.rb | 2 -- spec/rubocop/cop/naming/method_parameter_name_spec.rb | 2 -- spec/rubocop/cop/naming/predicate_name_spec.rb | 2 -- .../rubocop/cop/naming/rescued_exceptions_variable_name_spec.rb | 2 -- spec/rubocop/cop/naming/variable_name_spec.rb | 2 -- spec/rubocop/cop/naming/variable_number_spec.rb | 2 -- spec/rubocop/cop/security/json_load_spec.rb | 2 -- spec/rubocop/cop/security/marshal_load_spec.rb | 2 -- spec/rubocop/cop/security/yaml_load_spec.rb | 2 -- spec/rubocop/cop/style/access_modifier_declarations_spec.rb | 2 -- spec/rubocop/cop/style/alias_spec.rb | 2 -- spec/rubocop/cop/style/ascii_comments_spec.rb | 2 -- spec/rubocop/cop/style/bare_percent_literals_spec.rb | 2 -- spec/rubocop/cop/style/block_delimiters_spec.rb | 2 -- spec/rubocop/cop/style/class_and_module_children_spec.rb | 2 -- spec/rubocop/cop/style/class_check_spec.rb | 2 -- spec/rubocop/cop/style/command_literal_spec.rb | 2 -- spec/rubocop/cop/style/comment_annotation_spec.rb | 2 -- spec/rubocop/cop/style/copyright_spec.rb | 2 -- spec/rubocop/cop/style/date_time_spec.rb | 2 -- spec/rubocop/cop/style/dir_spec.rb | 2 -- spec/rubocop/cop/style/documentation_method_spec.rb | 2 -- spec/rubocop/cop/style/empty_method_spec.rb | 2 -- spec/rubocop/cop/style/encoding_spec.rb | 2 -- spec/rubocop/cop/style/expand_path_arguments_spec.rb | 2 -- spec/rubocop/cop/style/exponential_notation_spec.rb | 2 -- spec/rubocop/cop/style/float_division_spec.rb | 2 -- spec/rubocop/cop/style/for_spec.rb | 2 -- spec/rubocop/cop/style/format_string_spec.rb | 2 -- spec/rubocop/cop/style/format_string_token_spec.rb | 2 -- spec/rubocop/cop/style/frozen_string_literal_comment_spec.rb | 2 -- spec/rubocop/cop/style/hash_syntax_spec.rb | 2 -- spec/rubocop/cop/style/hash_transform_keys_spec.rb | 2 -- spec/rubocop/cop/style/hash_transform_values_spec.rb | 2 -- spec/rubocop/cop/style/if_inside_else_spec.rb | 2 -- spec/rubocop/cop/style/ip_addresses_spec.rb | 2 -- spec/rubocop/cop/style/lambda_call_spec.rb | 2 -- spec/rubocop/cop/style/lambda_spec.rb | 2 -- .../rubocop/cop/style/method_call_with_args_parentheses_spec.rb | 2 -- .../cop/style/method_call_without_args_parentheses_spec.rb | 2 -- spec/rubocop/cop/style/method_def_parentheses_spec.rb | 2 -- spec/rubocop/cop/style/min_max_spec.rb | 2 -- spec/rubocop/cop/style/mixin_grouping_spec.rb | 2 -- spec/rubocop/cop/style/module_function_spec.rb | 2 -- spec/rubocop/cop/style/multiline_memoization_spec.rb | 2 -- spec/rubocop/cop/style/multiline_method_signature_spec.rb | 2 -- spec/rubocop/cop/style/mutable_constant_spec.rb | 2 -- spec/rubocop/cop/style/next_spec.rb | 2 -- spec/rubocop/cop/style/nil_comparison_spec.rb | 2 -- spec/rubocop/cop/style/non_nil_check_spec.rb | 2 -- spec/rubocop/cop/style/not_spec.rb | 2 -- spec/rubocop/cop/style/numeric_literal_prefix_spec.rb | 2 -- spec/rubocop/cop/style/numeric_literals_spec.rb | 2 -- spec/rubocop/cop/style/numeric_predicate_spec.rb | 2 -- spec/rubocop/cop/style/option_hash_spec.rb | 2 -- spec/rubocop/cop/style/parallel_assignment_spec.rb | 2 -- spec/rubocop/cop/style/parentheses_around_condition_spec.rb | 2 -- spec/rubocop/cop/style/percent_literal_delimiters_spec.rb | 2 -- spec/rubocop/cop/style/percent_q_literals_spec.rb | 2 -- spec/rubocop/cop/style/preferred_hash_methods_spec.rb | 2 -- spec/rubocop/cop/style/raise_args_spec.rb | 2 -- spec/rubocop/cop/style/redundant_begin_spec.rb | 2 -- spec/rubocop/cop/style/redundant_return_spec.rb | 2 -- spec/rubocop/cop/style/regexp_literal_spec.rb | 2 -- spec/rubocop/cop/style/rescue_standard_error_spec.rb | 2 -- spec/rubocop/cop/style/safe_navigation_spec.rb | 2 -- spec/rubocop/cop/style/semicolon_spec.rb | 2 -- spec/rubocop/cop/style/signal_exception_spec.rb | 2 -- spec/rubocop/cop/style/single_line_block_params_spec.rb | 2 -- spec/rubocop/cop/style/slicing_with_range_spec.rb | 2 -- spec/rubocop/cop/style/special_global_vars_spec.rb | 2 -- spec/rubocop/cop/style/stabby_lambda_parentheses_spec.rb | 2 -- spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb | 2 -- spec/rubocop/cop/style/string_literals_spec.rb | 2 -- spec/rubocop/cop/style/string_methods_spec.rb | 2 -- spec/rubocop/cop/style/symbol_array_spec.rb | 2 -- spec/rubocop/cop/style/symbol_proc_spec.rb | 2 -- spec/rubocop/cop/style/ternary_parentheses_spec.rb | 2 -- spec/rubocop/cop/style/trailing_comma_in_arguments_spec.rb | 2 -- spec/rubocop/cop/style/trailing_comma_in_array_literal_spec.rb | 2 -- spec/rubocop/cop/style/trailing_comma_in_hash_literal_spec.rb | 2 -- spec/rubocop/cop/style/trivial_accessors_spec.rb | 2 -- spec/rubocop/cop/style/unpack_first_spec.rb | 2 -- spec/rubocop/cop/style/word_array_spec.rb | 2 -- spec/rubocop/cop/style/yoda_condition_spec.rb | 2 -- 163 files changed, 326 deletions(-) diff --git a/spec/rubocop/cop/bundler/duplicated_gem_spec.rb b/spec/rubocop/cop/bundler/duplicated_gem_spec.rb index ebe7598c168..b3e65e9ef71 100644 --- a/spec/rubocop/cop/bundler/duplicated_gem_spec.rb +++ b/spec/rubocop/cop/bundler/duplicated_gem_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Bundler::DuplicatedGem, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'Include' => ['**/Gemfile'] } } context 'when investigating Ruby files' do diff --git a/spec/rubocop/cop/bundler/gem_comment_spec.rb b/spec/rubocop/cop/bundler/gem_comment_spec.rb index dafb4da18e0..9d964d39006 100644 --- a/spec/rubocop/cop/bundler/gem_comment_spec.rb +++ b/spec/rubocop/cop/bundler/gem_comment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Bundler::GemComment, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'Include' => ['**/Gemfile'], diff --git a/spec/rubocop/cop/bundler/ordered_gems_spec.rb b/spec/rubocop/cop/bundler/ordered_gems_spec.rb index 1ff35cff750..7d800adf745 100644 --- a/spec/rubocop/cop/bundler/ordered_gems_spec.rb +++ b/spec/rubocop/cop/bundler/ordered_gems_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Bundler::OrderedGems, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'TreatCommentsAsGroupSeparators' => treat_comments_as_group_separators, diff --git a/spec/rubocop/cop/gemspec/ordered_dependencies_spec.rb b/spec/rubocop/cop/gemspec/ordered_dependencies_spec.rb index 027ee8cf5fc..a43490b48bf 100644 --- a/spec/rubocop/cop/gemspec/ordered_dependencies_spec.rb +++ b/spec/rubocop/cop/gemspec/ordered_dependencies_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Gemspec::OrderedDependencies, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'TreatCommentsAsGroupSeparators' => treat_comments_as_group_separators, diff --git a/spec/rubocop/cop/gemspec/required_ruby_version_spec.rb b/spec/rubocop/cop/gemspec/required_ruby_version_spec.rb index 24ee2a44cca..54b976fd34d 100644 --- a/spec/rubocop/cop/gemspec/required_ruby_version_spec.rb +++ b/spec/rubocop/cop/gemspec/required_ruby_version_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Gemspec::RequiredRubyVersion, :config do - subject(:cop) { described_class.new(config) } - context 'target ruby version > 2.7', :ruby27 do it 'registers an offense when `required_ruby_version` is lower than ' \ '`TargetRubyVersion`' do diff --git a/spec/rubocop/cop/gemspec/ruby_version_globals_usage_spec.rb b/spec/rubocop/cop/gemspec/ruby_version_globals_usage_spec.rb index 40d4cf976c7..8f6f0e671b8 100644 --- a/spec/rubocop/cop/gemspec/ruby_version_globals_usage_spec.rb +++ b/spec/rubocop/cop/gemspec/ruby_version_globals_usage_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Gemspec::RubyVersionGlobalsUsage, :config do - subject(:cop) { described_class.new(config) } - it 'registers an offense when using `RUBY_VERSION`' do expect_offense(<<~RUBY, '/path/to/foo.gemspec') Gem::Specification.new do |spec| diff --git a/spec/rubocop/cop/layout/assignment_indentation_spec.rb b/spec/rubocop/cop/layout/assignment_indentation_spec.rb index b1133f5434f..01c9dc628ba 100644 --- a/spec/rubocop/cop/layout/assignment_indentation_spec.rb +++ b/spec/rubocop/cop/layout/assignment_indentation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::AssignmentIndentation, :config do - subject(:cop) { described_class.new(config) } - let(:config) do RuboCop::Config.new('Layout/AssignmentIndentation' => { 'IndentationWidth' => cop_indent diff --git a/spec/rubocop/cop/layout/block_alignment_spec.rb b/spec/rubocop/cop/layout/block_alignment_spec.rb index 768f8e3edfc..88ff4c36ecd 100644 --- a/spec/rubocop/cop/layout/block_alignment_spec.rb +++ b/spec/rubocop/cop/layout/block_alignment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::BlockAlignment, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'EnforcedStyleAlignWith' => 'either' } end diff --git a/spec/rubocop/cop/layout/class_structure_spec.rb b/spec/rubocop/cop/layout/class_structure_spec.rb index ae21ad743bb..1fbbed9777c 100644 --- a/spec/rubocop/cop/layout/class_structure_spec.rb +++ b/spec/rubocop/cop/layout/class_structure_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::ClassStructure, :config do - subject(:cop) { described_class.new(config) } - let(:config) do RuboCop::Config.new( 'Layout/ClassStructure' => { diff --git a/spec/rubocop/cop/layout/def_end_alignment_spec.rb b/spec/rubocop/cop/layout/def_end_alignment_spec.rb index 96c85a92c96..1bc950a3cfc 100644 --- a/spec/rubocop/cop/layout/def_end_alignment_spec.rb +++ b/spec/rubocop/cop/layout/def_end_alignment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::DefEndAlignment, :config do - subject(:cop) { described_class.new(config) } - let(:source) do <<~RUBY foo def a diff --git a/spec/rubocop/cop/layout/dot_position_spec.rb b/spec/rubocop/cop/layout/dot_position_spec.rb index 9076ca0ca42..94fdb41c88e 100644 --- a/spec/rubocop/cop/layout/dot_position_spec.rb +++ b/spec/rubocop/cop/layout/dot_position_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::DotPosition, :config do - subject(:cop) { described_class.new(config) } - context 'Leading dots style' do let(:cop_config) { { 'EnforcedStyle' => 'leading' } } diff --git a/spec/rubocop/cop/layout/empty_comment_spec.rb b/spec/rubocop/cop/layout/empty_comment_spec.rb index f1547a84ef2..0de1caa3ef4 100644 --- a/spec/rubocop/cop/layout/empty_comment_spec.rb +++ b/spec/rubocop/cop/layout/empty_comment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyComment, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'AllowBorderComment' => true, 'AllowMarginComment' => true } end diff --git a/spec/rubocop/cop/layout/empty_line_between_defs_spec.rb b/spec/rubocop/cop/layout/empty_line_between_defs_spec.rb index ac931e82f54..bffd802a9ef 100644 --- a/spec/rubocop/cop/layout/empty_line_between_defs_spec.rb +++ b/spec/rubocop/cop/layout/empty_line_between_defs_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyLineBetweenDefs, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowAdjacentOneLineDefs' => false } } it 'finds offenses in inner classes' do diff --git a/spec/rubocop/cop/layout/empty_lines_around_access_modifier_spec.rb b/spec/rubocop/cop/layout/empty_lines_around_access_modifier_spec.rb index 4498d59b569..140a91a01d0 100644 --- a/spec/rubocop/cop/layout/empty_lines_around_access_modifier_spec.rb +++ b/spec/rubocop/cop/layout/empty_lines_around_access_modifier_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyLinesAroundAccessModifier, :config do - subject(:cop) { described_class.new(config) } - context 'EnforcedStyle is `around`' do let(:cop_config) { { 'EnforcedStyle' => 'around' } } diff --git a/spec/rubocop/cop/layout/empty_lines_around_arguments_spec.rb b/spec/rubocop/cop/layout/empty_lines_around_arguments_spec.rb index 42a7ea32763..b3d71410f37 100644 --- a/spec/rubocop/cop/layout/empty_lines_around_arguments_spec.rb +++ b/spec/rubocop/cop/layout/empty_lines_around_arguments_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyLinesAroundArguments, :config do - subject(:cop) { described_class.new(config) } - context 'when extra lines' do it 'registers offense for empty line before arg' do inspect_source(<<~RUBY) diff --git a/spec/rubocop/cop/layout/empty_lines_around_block_body_spec.rb b/spec/rubocop/cop/layout/empty_lines_around_block_body_spec.rb index 7c00e7f5404..eadee755313 100644 --- a/spec/rubocop/cop/layout/empty_lines_around_block_body_spec.rb +++ b/spec/rubocop/cop/layout/empty_lines_around_block_body_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyLinesAroundBlockBody, :config do - subject(:cop) { described_class.new(config) } - # Test blocks using both {} and do..end [%w[{ }], %w[do end]].each do |open, close| context "when EnforcedStyle is no_empty_lines for #{open} #{close} block" do diff --git a/spec/rubocop/cop/layout/empty_lines_around_class_body_spec.rb b/spec/rubocop/cop/layout/empty_lines_around_class_body_spec.rb index f4b76f98228..ca292273d9f 100644 --- a/spec/rubocop/cop/layout/empty_lines_around_class_body_spec.rb +++ b/spec/rubocop/cop/layout/empty_lines_around_class_body_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyLinesAroundClassBody, :config do - subject(:cop) { described_class.new(config) } - let(:extra_begin) { 'Extra empty line detected at class body beginning.' } let(:extra_end) { 'Extra empty line detected at class body end.' } let(:missing_begin) { 'Empty line missing at class body beginning.' } diff --git a/spec/rubocop/cop/layout/empty_lines_around_module_body_spec.rb b/spec/rubocop/cop/layout/empty_lines_around_module_body_spec.rb index 8b1de597e11..301b11a4d38 100644 --- a/spec/rubocop/cop/layout/empty_lines_around_module_body_spec.rb +++ b/spec/rubocop/cop/layout/empty_lines_around_module_body_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EmptyLinesAroundModuleBody, :config do - subject(:cop) { described_class.new(config) } - let(:extra_begin) { 'Extra empty line detected at module body beginning.' } let(:extra_end) { 'Extra empty line detected at module body end.' } let(:missing_begin) { 'Empty line missing at module body beginning.' } diff --git a/spec/rubocop/cop/layout/end_alignment_spec.rb b/spec/rubocop/cop/layout/end_alignment_spec.rb index e39f9417b91..b68c2ae8d34 100644 --- a/spec/rubocop/cop/layout/end_alignment_spec.rb +++ b/spec/rubocop/cop/layout/end_alignment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EndAlignment, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'EnforcedStyleAlignWith' => 'keyword', 'AutoCorrect' => true } end diff --git a/spec/rubocop/cop/layout/end_of_line_spec.rb b/spec/rubocop/cop/layout/end_of_line_spec.rb index db2fbbccf3b..5f974a2d3e0 100644 --- a/spec/rubocop/cop/layout/end_of_line_spec.rb +++ b/spec/rubocop/cop/layout/end_of_line_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::EndOfLine, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'all configurations' do it 'accepts an empty file' do inspect_source_file('') diff --git a/spec/rubocop/cop/layout/extra_spacing_spec.rb b/spec/rubocop/cop/layout/extra_spacing_spec.rb index 3635ea10c33..b1555c73581 100644 --- a/spec/rubocop/cop/layout/extra_spacing_spec.rb +++ b/spec/rubocop/cop/layout/extra_spacing_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::ExtraSpacing, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'common behavior' do it 'registers an offense and corrects alignment with token ' \ 'not preceded by space' do diff --git a/spec/rubocop/cop/layout/first_argument_indentation_spec.rb b/spec/rubocop/cop/layout/first_argument_indentation_spec.rb index d45591692d6..b04347c4fb6 100644 --- a/spec/rubocop/cop/layout/first_argument_indentation_spec.rb +++ b/spec/rubocop/cop/layout/first_argument_indentation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::FirstArgumentIndentation, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'EnforcedStyle' => style } end diff --git a/spec/rubocop/cop/layout/first_parameter_indentation_spec.rb b/spec/rubocop/cop/layout/first_parameter_indentation_spec.rb index 5e6905d2a08..4d631a97a4b 100644 --- a/spec/rubocop/cop/layout/first_parameter_indentation_spec.rb +++ b/spec/rubocop/cop/layout/first_parameter_indentation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::FirstParameterIndentation, :config do - subject(:cop) { described_class.new(config) } - let(:config) do supported_styles = { 'SupportedStyles' => %w[consistent align_parentheses] diff --git a/spec/rubocop/cop/layout/hash_alignment_spec.rb b/spec/rubocop/cop/layout/hash_alignment_spec.rb index 266cc06ae7b..e5588ca7e22 100644 --- a/spec/rubocop/cop/layout/hash_alignment_spec.rb +++ b/spec/rubocop/cop/layout/hash_alignment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::HashAlignment, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'EnforcedHashRocketStyle' => 'key', diff --git a/spec/rubocop/cop/layout/heredoc_indentation_spec.rb b/spec/rubocop/cop/layout/heredoc_indentation_spec.rb index ed2e61e656a..ba018f5b869 100644 --- a/spec/rubocop/cop/layout/heredoc_indentation_spec.rb +++ b/spec/rubocop/cop/layout/heredoc_indentation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::HeredocIndentation, :config do - subject(:cop) { described_class.new(config) } - let(:allow_heredoc) { true } let(:other_cops) do { diff --git a/spec/rubocop/cop/layout/indentation_consistency_spec.rb b/spec/rubocop/cop/layout/indentation_consistency_spec.rb index 0c80af6cfbe..c4320c2445f 100644 --- a/spec/rubocop/cop/layout/indentation_consistency_spec.rb +++ b/spec/rubocop/cop/layout/indentation_consistency_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::IndentationConsistency, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'EnforcedStyle' => 'normal' } } context 'with top-level code' do diff --git a/spec/rubocop/cop/layout/leading_comment_space_spec.rb b/spec/rubocop/cop/layout/leading_comment_space_spec.rb index 3b30f5e4452..77d1a0ee9d4 100644 --- a/spec/rubocop/cop/layout/leading_comment_space_spec.rb +++ b/spec/rubocop/cop/layout/leading_comment_space_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::LeadingCommentSpace, :config do - subject(:cop) { described_class.new(config) } - it 'registers an offense and corrects comment without leading space' do expect_offense(<<~RUBY) #missing space diff --git a/spec/rubocop/cop/layout/leading_empty_lines_spec.rb b/spec/rubocop/cop/layout/leading_empty_lines_spec.rb index 651a5b331b8..e0ed5a1c4fb 100644 --- a/spec/rubocop/cop/layout/leading_empty_lines_spec.rb +++ b/spec/rubocop/cop/layout/leading_empty_lines_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::LeadingEmptyLines, :config do - subject(:cop) { described_class.new(config) } - it 'allows an empty input' do expect_no_offenses('') end diff --git a/spec/rubocop/cop/layout/line_length_spec.rb b/spec/rubocop/cop/layout/line_length_spec.rb index b35e6cc25a8..a6e76ba0e6e 100644 --- a/spec/rubocop/cop/layout/line_length_spec.rb +++ b/spec/rubocop/cop/layout/line_length_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::LineLength, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'Max' => 80, 'IgnoredPatterns' => nil } } let(:config) do diff --git a/spec/rubocop/cop/layout/multiline_array_brace_layout_spec.rb b/spec/rubocop/cop/layout/multiline_array_brace_layout_spec.rb index 6de159d7e53..8715583ba84 100644 --- a/spec/rubocop/cop/layout/multiline_array_brace_layout_spec.rb +++ b/spec/rubocop/cop/layout/multiline_array_brace_layout_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::MultilineArrayBraceLayout, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'EnforcedStyle' => 'symmetrical' } } it 'ignores implicit arrays' do diff --git a/spec/rubocop/cop/layout/multiline_assignment_layout_spec.rb b/spec/rubocop/cop/layout/multiline_assignment_layout_spec.rb index 1643b47183b..91d62e35df6 100644 --- a/spec/rubocop/cop/layout/multiline_assignment_layout_spec.rb +++ b/spec/rubocop/cop/layout/multiline_assignment_layout_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::MultilineAssignmentLayout, :config do - subject(:cop) { described_class.new(config) } - let(:supported_types) { %w[if] } let(:cop_config) do diff --git a/spec/rubocop/cop/layout/multiline_hash_brace_layout_spec.rb b/spec/rubocop/cop/layout/multiline_hash_brace_layout_spec.rb index 24530867715..9dff8e9e7d1 100644 --- a/spec/rubocop/cop/layout/multiline_hash_brace_layout_spec.rb +++ b/spec/rubocop/cop/layout/multiline_hash_brace_layout_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::MultilineHashBraceLayout, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'EnforcedStyle' => 'symmetrical' } } it 'ignores implicit hashes' do 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 574c44562f9..961ea1be578 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 @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::MultilineMethodCallBraceLayout, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'EnforcedStyle' => 'symmetrical' } } it 'ignores implicit calls' do diff --git a/spec/rubocop/cop/layout/multiline_method_definition_brace_layout_spec.rb b/spec/rubocop/cop/layout/multiline_method_definition_brace_layout_spec.rb index af3b15ea7da..6f340f3d69b 100644 --- a/spec/rubocop/cop/layout/multiline_method_definition_brace_layout_spec.rb +++ b/spec/rubocop/cop/layout/multiline_method_definition_brace_layout_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::MultilineMethodDefinitionBraceLayout, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'EnforcedStyle' => 'symmetrical' } } it 'ignores implicit defs' do diff --git a/spec/rubocop/cop/layout/rescue_ensure_alignment_spec.rb b/spec/rubocop/cop/layout/rescue_ensure_alignment_spec.rb index e72b6a98f4c..2b4afb4f3d1 100644 --- a/spec/rubocop/cop/layout/rescue_ensure_alignment_spec.rb +++ b/spec/rubocop/cop/layout/rescue_ensure_alignment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::RescueEnsureAlignment, :config do - subject(:cop) { described_class.new(config) } - it 'accepts the modifier form' do expect_no_offenses('test rescue nil') end diff --git a/spec/rubocop/cop/layout/space_around_block_parameters_spec.rb b/spec/rubocop/cop/layout/space_around_block_parameters_spec.rb index a0ed39eca69..8ba4f292ea0 100644 --- a/spec/rubocop/cop/layout/space_around_block_parameters_spec.rb +++ b/spec/rubocop/cop/layout/space_around_block_parameters_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceAroundBlockParameters, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'common behavior' do it 'accepts an empty block' do expect_no_offenses('{}.each {}') diff --git a/spec/rubocop/cop/layout/space_around_equals_in_parameter_default_spec.rb b/spec/rubocop/cop/layout/space_around_equals_in_parameter_default_spec.rb index 0322a95fb8a..8a3c4d9377c 100644 --- a/spec/rubocop/cop/layout/space_around_equals_in_parameter_default_spec.rb +++ b/spec/rubocop/cop/layout/space_around_equals_in_parameter_default_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceAroundEqualsInParameterDefault, :config do - subject(:cop) { described_class.new(config) } - context 'when EnforcedStyle is space' do let(:cop_config) { { 'EnforcedStyle' => 'space' } } diff --git a/spec/rubocop/cop/layout/space_before_block_braces_spec.rb b/spec/rubocop/cop/layout/space_before_block_braces_spec.rb index 76cb26cd7c4..2e306fd490a 100644 --- a/spec/rubocop/cop/layout/space_before_block_braces_spec.rb +++ b/spec/rubocop/cop/layout/space_before_block_braces_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceBeforeBlockBraces, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'EnforcedStyle' => 'space' } } context 'when EnforcedStyle is space' do diff --git a/spec/rubocop/cop/layout/space_before_first_arg_spec.rb b/spec/rubocop/cop/layout/space_before_first_arg_spec.rb index 737ee5c75d7..649bce8b6a5 100644 --- a/spec/rubocop/cop/layout/space_before_first_arg_spec.rb +++ b/spec/rubocop/cop/layout/space_before_first_arg_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceBeforeFirstArg, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowForAlignment' => true } } context 'for method calls without parentheses' do diff --git a/spec/rubocop/cop/layout/space_in_lambda_literal_spec.rb b/spec/rubocop/cop/layout/space_in_lambda_literal_spec.rb index fdd1b051910..6a01606de40 100644 --- a/spec/rubocop/cop/layout/space_in_lambda_literal_spec.rb +++ b/spec/rubocop/cop/layout/space_in_lambda_literal_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInLambdaLiteral, :config do - subject(:cop) { described_class.new(config) } - context 'when configured to enforce spaces' do let(:cop_config) { { 'EnforcedStyle' => 'require_space' } } diff --git a/spec/rubocop/cop/layout/space_inside_array_literal_brackets_spec.rb b/spec/rubocop/cop/layout/space_inside_array_literal_brackets_spec.rb index b798e4d76ab..84f4fac046d 100644 --- a/spec/rubocop/cop/layout/space_inside_array_literal_brackets_spec.rb +++ b/spec/rubocop/cop/layout/space_inside_array_literal_brackets_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideArrayLiteralBrackets, :config do - subject(:cop) { described_class.new(config) } - it 'does not register offense for any kind of reference brackets' do expect_no_offenses(<<~RUBY) a[1] diff --git a/spec/rubocop/cop/layout/space_inside_hash_literal_braces_spec.rb b/spec/rubocop/cop/layout/space_inside_hash_literal_braces_spec.rb index b8651b5cc4d..4e62378ad1b 100644 --- a/spec/rubocop/cop/layout/space_inside_hash_literal_braces_spec.rb +++ b/spec/rubocop/cop/layout/space_inside_hash_literal_braces_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideHashLiteralBraces, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'EnforcedStyle' => 'space' } } context 'with space inside empty braces not allowed' do diff --git a/spec/rubocop/cop/layout/space_inside_parens_spec.rb b/spec/rubocop/cop/layout/space_inside_parens_spec.rb index 39d43de62a9..fc9e48cdeca 100644 --- a/spec/rubocop/cop/layout/space_inside_parens_spec.rb +++ b/spec/rubocop/cop/layout/space_inside_parens_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideParens, :config do - subject(:cop) { described_class.new(config) } - context 'when EnforcedStyle is no_space' do let(:cop_config) { { 'EnforcedStyle' => 'no_space' } } diff --git a/spec/rubocop/cop/layout/space_inside_reference_brackets_spec.rb b/spec/rubocop/cop/layout/space_inside_reference_brackets_spec.rb index e522dfa79bb..aa82ff2c340 100644 --- a/spec/rubocop/cop/layout/space_inside_reference_brackets_spec.rb +++ b/spec/rubocop/cop/layout/space_inside_reference_brackets_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideReferenceBrackets, :config do - subject(:cop) { described_class.new(config) } - context 'with space inside empty brackets not allowed' do let(:cop_config) { { 'EnforcedStyleForEmptyBrackets' => 'no_space' } } diff --git a/spec/rubocop/cop/layout/space_inside_string_interpolation_spec.rb b/spec/rubocop/cop/layout/space_inside_string_interpolation_spec.rb index 917cf39309d..50f5d28f96e 100644 --- a/spec/rubocop/cop/layout/space_inside_string_interpolation_spec.rb +++ b/spec/rubocop/cop/layout/space_inside_string_interpolation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::SpaceInsideStringInterpolation, :config do - subject(:cop) { described_class.new(config) } - context 'when EnforcedStyle is no_space' do let(:cop_config) { { 'EnforcedStyle' => 'no_space' } } diff --git a/spec/rubocop/cop/layout/trailing_empty_lines_spec.rb b/spec/rubocop/cop/layout/trailing_empty_lines_spec.rb index bfc1224677e..70fc20b91be 100644 --- a/spec/rubocop/cop/layout/trailing_empty_lines_spec.rb +++ b/spec/rubocop/cop/layout/trailing_empty_lines_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::TrailingEmptyLines, :config do - subject(:cop) { described_class.new(config) } - context 'when EnforcedStyle is final_newline' do let(:cop_config) { { 'EnforcedStyle' => 'final_newline' } } diff --git a/spec/rubocop/cop/layout/trailing_whitespace_spec.rb b/spec/rubocop/cop/layout/trailing_whitespace_spec.rb index 70e972d2479..53f67120302 100644 --- a/spec/rubocop/cop/layout/trailing_whitespace_spec.rb +++ b/spec/rubocop/cop/layout/trailing_whitespace_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Layout::TrailingWhitespace, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowInHeredoc' => false } } it 'registers an offense for a line ending with space' do diff --git a/spec/rubocop/cop/lint/assignment_in_condition_spec.rb b/spec/rubocop/cop/lint/assignment_in_condition_spec.rb index 7e66b241459..6a2fac253e4 100644 --- a/spec/rubocop/cop/lint/assignment_in_condition_spec.rb +++ b/spec/rubocop/cop/lint/assignment_in_condition_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::AssignmentInCondition, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowSafeAssignment' => true } } it 'registers an offense for lvar assignment in condition' do diff --git a/spec/rubocop/cop/lint/boolean_symbol_spec.rb b/spec/rubocop/cop/lint/boolean_symbol_spec.rb index b6f15cea43b..6c86061731c 100644 --- a/spec/rubocop/cop/lint/boolean_symbol_spec.rb +++ b/spec/rubocop/cop/lint/boolean_symbol_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::BooleanSymbol, :config do - subject(:cop) { described_class.new(config) } - it 'registers an offense when using `:true`' do expect_offense(<<~RUBY) :true diff --git a/spec/rubocop/cop/lint/debugger_spec.rb b/spec/rubocop/cop/lint/debugger_spec.rb index 4aa470f6cda..f052f67837b 100644 --- a/spec/rubocop/cop/lint/debugger_spec.rb +++ b/spec/rubocop/cop/lint/debugger_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::Debugger, :config do - subject(:cop) { described_class.new(config) } - shared_examples_for 'debugger' do |name, src| it "reports an offense for a #{name} call" do inspect_source(src) diff --git a/spec/rubocop/cop/lint/empty_when_spec.rb b/spec/rubocop/cop/lint/empty_when_spec.rb index e65a8c20c6e..c95388d80d3 100644 --- a/spec/rubocop/cop/lint/empty_when_spec.rb +++ b/spec/rubocop/cop/lint/empty_when_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::EmptyWhen, :config do - subject(:cop) { described_class.new(config) } - before do inspect_source(source) end diff --git a/spec/rubocop/cop/lint/erb_new_arguments_spec.rb b/spec/rubocop/cop/lint/erb_new_arguments_spec.rb index 8ff1bd1cc2a..2b237eced42 100644 --- a/spec/rubocop/cop/lint/erb_new_arguments_spec.rb +++ b/spec/rubocop/cop/lint/erb_new_arguments_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ErbNewArguments, :config do - subject(:cop) { described_class.new(config) } - context '<= Ruby 2.5', :ruby25 do it 'does not register an offense when using `ERB.new` ' \ 'with non-keyword arguments' do diff --git a/spec/rubocop/cop/lint/inherit_exception_spec.rb b/spec/rubocop/cop/lint/inherit_exception_spec.rb index ecb6eabdcd7..2133652e444 100644 --- a/spec/rubocop/cop/lint/inherit_exception_spec.rb +++ b/spec/rubocop/cop/lint/inherit_exception_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::InheritException, :config do - subject(:cop) { described_class.new(config) } - context 'when class inherits from `Exception`' do context 'with enforced style set to `runtime_error`' do let(:cop_config) { { 'EnforcedStyle' => 'runtime_error' } } diff --git a/spec/rubocop/cop/lint/missing_cop_enable_directive_spec.rb b/spec/rubocop/cop/lint/missing_cop_enable_directive_spec.rb index d15adf4002e..1bb7fc5e22c 100644 --- a/spec/rubocop/cop/lint/missing_cop_enable_directive_spec.rb +++ b/spec/rubocop/cop/lint/missing_cop_enable_directive_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::MissingCopEnableDirective, :config do - subject(:cop) { described_class.new(config) } - context 'when the maximum range size is infinite' do let(:cop_config) { { 'MaximumRangeSize' => Float::INFINITY } } diff --git a/spec/rubocop/cop/lint/ordered_magic_comments_spec.rb b/spec/rubocop/cop/lint/ordered_magic_comments_spec.rb index 2125f4692a2..b46a825810d 100644 --- a/spec/rubocop/cop/lint/ordered_magic_comments_spec.rb +++ b/spec/rubocop/cop/lint/ordered_magic_comments_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::OrderedMagicComments, :config do - subject(:cop) { described_class.new(config) } - it 'registers an offense and corrects when an `encoding` magic comment ' \ 'does not precede all other magic comments' do expect_offense(<<~RUBY) diff --git a/spec/rubocop/cop/lint/raise_exception_spec.rb b/spec/rubocop/cop/lint/raise_exception_spec.rb index cdc208cfe01..c1172bcab42 100644 --- a/spec/rubocop/cop/lint/raise_exception_spec.rb +++ b/spec/rubocop/cop/lint/raise_exception_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RaiseException, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowedImplicitNamespaces' => ['Gem'] } } it 'registers an offense for `raise` with `::Exception`' do diff --git a/spec/rubocop/cop/lint/redundant_require_statement_spec.rb b/spec/rubocop/cop/lint/redundant_require_statement_spec.rb index 1a6ac83f298..4629392468a 100644 --- a/spec/rubocop/cop/lint/redundant_require_statement_spec.rb +++ b/spec/rubocop/cop/lint/redundant_require_statement_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::RedundantRequireStatement, :config do - subject(:cop) { described_class.new(config) } - it "registers an offense and corrects when using `require 'enumerator'`" do expect_offense(<<~RUBY) require 'enumerator' diff --git a/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb b/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb index d0359538b27..7c9e1f0d475 100644 --- a/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb +++ b/spec/rubocop/cop/lint/safe_navigation_chain_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SafeNavigationChain, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'AcceptedMethods' => %w[present? blank? try presence] } end diff --git a/spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb b/spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb index d39d56104cd..67a86577712 100644 --- a/spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb +++ b/spec/rubocop/cop/lint/safe_navigation_consistency_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SafeNavigationConsistency, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'AllowedMethods' => %w[present? blank? try presence] } end diff --git a/spec/rubocop/cop/lint/shadowed_argument_spec.rb b/spec/rubocop/cop/lint/shadowed_argument_spec.rb index 863dd2586ea..b5df5c067e2 100644 --- a/spec/rubocop/cop/lint/shadowed_argument_spec.rb +++ b/spec/rubocop/cop/lint/shadowed_argument_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::ShadowedArgument, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'IgnoreImplicitReferences' => false } } describe 'method argument shadowing' do diff --git a/spec/rubocop/cop/lint/suppressed_exception_spec.rb b/spec/rubocop/cop/lint/suppressed_exception_spec.rb index e528551526a..4a5bb488a59 100644 --- a/spec/rubocop/cop/lint/suppressed_exception_spec.rb +++ b/spec/rubocop/cop/lint/suppressed_exception_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::SuppressedException, :config do - subject(:cop) { described_class.new(config) } - context 'with AllowComments set to false' do let(:cop_config) { { 'AllowComments' => false } } diff --git a/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb b/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb index f6906e33b35..b8da940ef6b 100644 --- a/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb +++ b/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnderscorePrefixedVariableName, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowKeywordBlockArguments' => false } } context 'when an underscore-prefixed variable is used' do diff --git a/spec/rubocop/cop/lint/unified_integer_spec.rb b/spec/rubocop/cop/lint/unified_integer_spec.rb index 930dcddb524..d52291f784c 100644 --- a/spec/rubocop/cop/lint/unified_integer_spec.rb +++ b/spec/rubocop/cop/lint/unified_integer_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnifiedInteger, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'registers an offense' do |klass| context "when #{klass}" do context 'without any decorations' do diff --git a/spec/rubocop/cop/lint/unused_block_argument_spec.rb b/spec/rubocop/cop/lint/unused_block_argument_spec.rb index 1747f73e67e..ac358974a1f 100644 --- a/spec/rubocop/cop/lint/unused_block_argument_spec.rb +++ b/spec/rubocop/cop/lint/unused_block_argument_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnusedBlockArgument, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowUnusedKeywordArguments' => false } } shared_examples 'auto-correction' do |name, old_source, new_source| diff --git a/spec/rubocop/cop/lint/unused_method_argument_spec.rb b/spec/rubocop/cop/lint/unused_method_argument_spec.rb index 0c38209068b..102fb8b7c07 100644 --- a/spec/rubocop/cop/lint/unused_method_argument_spec.rb +++ b/spec/rubocop/cop/lint/unused_method_argument_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Lint::UnusedMethodArgument, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'AllowUnusedKeywordArguments' => false, diff --git a/spec/rubocop/cop/metrics/abc_size_spec.rb b/spec/rubocop/cop/metrics/abc_size_spec.rb index f9a1c3d9e3b..4fa9fa92a9f 100644 --- a/spec/rubocop/cop/metrics/abc_size_spec.rb +++ b/spec/rubocop/cop/metrics/abc_size_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::AbcSize, :config do - subject(:cop) { described_class.new(config) } - context 'when Max is 0' do let(:cop_config) { { 'Max' => 0 } } diff --git a/spec/rubocop/cop/metrics/block_length_spec.rb b/spec/rubocop/cop/metrics/block_length_spec.rb index b445a99e671..76679fac92a 100644 --- a/spec/rubocop/cop/metrics/block_length_spec.rb +++ b/spec/rubocop/cop/metrics/block_length_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::BlockLength, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'Max' => 2, 'CountComments' => false } } shared_examples 'ignoring an offense on an excluded method' do |excluded| diff --git a/spec/rubocop/cop/metrics/block_nesting_spec.rb b/spec/rubocop/cop/metrics/block_nesting_spec.rb index 38677b92b98..e3202a4441c 100644 --- a/spec/rubocop/cop/metrics/block_nesting_spec.rb +++ b/spec/rubocop/cop/metrics/block_nesting_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::BlockNesting, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'Max' => 2 } } it 'accepts `Max` levels of nesting' do diff --git a/spec/rubocop/cop/metrics/class_length_spec.rb b/spec/rubocop/cop/metrics/class_length_spec.rb index ba95ff6f26b..3a227e2463f 100644 --- a/spec/rubocop/cop/metrics/class_length_spec.rb +++ b/spec/rubocop/cop/metrics/class_length_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::ClassLength, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'Max' => 5, 'CountComments' => false } } it 'rejects a class with more than 5 lines' do diff --git a/spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb b/spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb index c176c2422ae..127767d87c4 100644 --- a/spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb +++ b/spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::CyclomaticComplexity, :config do - subject(:cop) { described_class.new(config) } - context 'when Max is 1' do let(:cop_config) { { 'Max' => 1 } } diff --git a/spec/rubocop/cop/metrics/method_length_spec.rb b/spec/rubocop/cop/metrics/method_length_spec.rb index 46f2e953b19..3ff5eeceacc 100644 --- a/spec/rubocop/cop/metrics/method_length_spec.rb +++ b/spec/rubocop/cop/metrics/method_length_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::MethodLength, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'Max' => 5, 'CountComments' => false } } context 'when method is an instance method' do diff --git a/spec/rubocop/cop/metrics/module_length_spec.rb b/spec/rubocop/cop/metrics/module_length_spec.rb index 0e13eee8a9e..0150563d1c9 100644 --- a/spec/rubocop/cop/metrics/module_length_spec.rb +++ b/spec/rubocop/cop/metrics/module_length_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::ModuleLength, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'Max' => 5, 'CountComments' => false } } it 'rejects a module with more than 5 lines' do diff --git a/spec/rubocop/cop/metrics/parameter_lists_spec.rb b/spec/rubocop/cop/metrics/parameter_lists_spec.rb index 6ca9af6da0d..c2e012eadd3 100644 --- a/spec/rubocop/cop/metrics/parameter_lists_spec.rb +++ b/spec/rubocop/cop/metrics/parameter_lists_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::ParameterLists, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'Max' => 4, diff --git a/spec/rubocop/cop/metrics/perceived_complexity_spec.rb b/spec/rubocop/cop/metrics/perceived_complexity_spec.rb index a457b63895b..8eb470188a5 100644 --- a/spec/rubocop/cop/metrics/perceived_complexity_spec.rb +++ b/spec/rubocop/cop/metrics/perceived_complexity_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Metrics::PerceivedComplexity, :config do - subject(:cop) { described_class.new(config) } - context 'when Max is 1' do let(:cop_config) { { 'Max' => 1 } } diff --git a/spec/rubocop/cop/naming/block_parameter_name_spec.rb b/spec/rubocop/cop/naming/block_parameter_name_spec.rb index c528c4cd462..c2da63c39a3 100644 --- a/spec/rubocop/cop/naming/block_parameter_name_spec.rb +++ b/spec/rubocop/cop/naming/block_parameter_name_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::BlockParameterName, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'MinNameLength' => 2, diff --git a/spec/rubocop/cop/naming/heredoc_delimiter_case_spec.rb b/spec/rubocop/cop/naming/heredoc_delimiter_case_spec.rb index 03c3bdaeea1..d5c12385e4e 100644 --- a/spec/rubocop/cop/naming/heredoc_delimiter_case_spec.rb +++ b/spec/rubocop/cop/naming/heredoc_delimiter_case_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::HeredocDelimiterCase, :config do - subject(:cop) { described_class.new(config) } - let(:config) do RuboCop::Config.new(described_class.badge.to_s => cop_config) end diff --git a/spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb b/spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb index 578a971b96c..1a44444c14d 100644 --- a/spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb +++ b/spec/rubocop/cop/naming/heredoc_delimiter_naming_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::HeredocDelimiterNaming, :config do - subject(:cop) { described_class.new(config) } - let(:config) do RuboCop::Config.new(described_class.badge.to_s => cop_config) end diff --git a/spec/rubocop/cop/naming/memoized_instance_variable_name_spec.rb b/spec/rubocop/cop/naming/memoized_instance_variable_name_spec.rb index 7dd1509c58d..881086a13eb 100644 --- a/spec/rubocop/cop/naming/memoized_instance_variable_name_spec.rb +++ b/spec/rubocop/cop/naming/memoized_instance_variable_name_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::MemoizedInstanceVariableName, :config do - subject(:cop) { described_class.new(config) } - context 'with default EnforcedStyleForLeadingUnderscores => disallowed' do let(:cop_config) do { 'EnforcedStyleForLeadingUnderscores' => 'disallowed' } diff --git a/spec/rubocop/cop/naming/method_name_spec.rb b/spec/rubocop/cop/naming/method_name_spec.rb index c950532fb6d..f2659c8b885 100644 --- a/spec/rubocop/cop/naming/method_name_spec.rb +++ b/spec/rubocop/cop/naming/method_name_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::MethodName, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'never accepted' do |enforced_style| it 'registers an offense for mixed snake case and camel case in attr.' do expect_offense(<<~RUBY) diff --git a/spec/rubocop/cop/naming/method_parameter_name_spec.rb b/spec/rubocop/cop/naming/method_parameter_name_spec.rb index 3ea83f109bd..d675094a9fd 100644 --- a/spec/rubocop/cop/naming/method_parameter_name_spec.rb +++ b/spec/rubocop/cop/naming/method_parameter_name_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::MethodParameterName, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'MinNameLength' => 3, diff --git a/spec/rubocop/cop/naming/predicate_name_spec.rb b/spec/rubocop/cop/naming/predicate_name_spec.rb index 986d2922ff2..8d8cc78aad7 100644 --- a/spec/rubocop/cop/naming/predicate_name_spec.rb +++ b/spec/rubocop/cop/naming/predicate_name_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::PredicateName, :config do - subject(:cop) { described_class.new(config) } - context 'with restricted prefixes' do let(:cop_config) do { 'NamePrefix' => %w[has_ is_], diff --git a/spec/rubocop/cop/naming/rescued_exceptions_variable_name_spec.rb b/spec/rubocop/cop/naming/rescued_exceptions_variable_name_spec.rb index 91fc0d75c34..bc9ba0d1724 100644 --- a/spec/rubocop/cop/naming/rescued_exceptions_variable_name_spec.rb +++ b/spec/rubocop/cop/naming/rescued_exceptions_variable_name_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::RescuedExceptionsVariableName, :config do - subject(:cop) { described_class.new(config) } - context 'with default config' do context 'with explicit rescue' do context 'with `Exception` variable' do diff --git a/spec/rubocop/cop/naming/variable_name_spec.rb b/spec/rubocop/cop/naming/variable_name_spec.rb index 69d8fc8fbfa..f7f4798fed8 100644 --- a/spec/rubocop/cop/naming/variable_name_spec.rb +++ b/spec/rubocop/cop/naming/variable_name_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::VariableName, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'always accepted' do it 'accepts screaming snake case globals' do expect_no_offenses('$MY_GLOBAL = 0') diff --git a/spec/rubocop/cop/naming/variable_number_spec.rb b/spec/rubocop/cop/naming/variable_number_spec.rb index 25a43b47803..b5c4e574f8b 100644 --- a/spec/rubocop/cop/naming/variable_number_spec.rb +++ b/spec/rubocop/cop/naming/variable_number_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Naming::VariableNumber, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'offense' do |style, variable, style_to_allow_offenses| it "registers an offense for #{Array(variable).first} in #{style}" do inspect_source(Array(variable).map { |v| "#{v} = 1" }.join("\n")) diff --git a/spec/rubocop/cop/security/json_load_spec.rb b/spec/rubocop/cop/security/json_load_spec.rb index 2a8da215850..fe742492d47 100644 --- a/spec/rubocop/cop/security/json_load_spec.rb +++ b/spec/rubocop/cop/security/json_load_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Security::JSONLoad, :config do - subject(:cop) { described_class.new(config) } - it 'registers an offense and corrects JSON.load' do expect_offense(<<~RUBY) JSON.load(arg) diff --git a/spec/rubocop/cop/security/marshal_load_spec.rb b/spec/rubocop/cop/security/marshal_load_spec.rb index 232527edb15..c84a8d332ca 100644 --- a/spec/rubocop/cop/security/marshal_load_spec.rb +++ b/spec/rubocop/cop/security/marshal_load_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Security::MarshalLoad, :config do - subject(:cop) { described_class.new(config) } - it 'registers an offense for using Marshal.load' do expect_offense(<<~RUBY) Marshal.load('{}') diff --git a/spec/rubocop/cop/security/yaml_load_spec.rb b/spec/rubocop/cop/security/yaml_load_spec.rb index 8f46c91a657..1c3e358d8c9 100644 --- a/spec/rubocop/cop/security/yaml_load_spec.rb +++ b/spec/rubocop/cop/security/yaml_load_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Security::YAMLLoad, :config do - subject(:cop) { described_class.new(config) } - it 'does not register an offense for YAML.dump' do expect_no_offenses(<<~RUBY) YAML.dump("foo") diff --git a/spec/rubocop/cop/style/access_modifier_declarations_spec.rb b/spec/rubocop/cop/style/access_modifier_declarations_spec.rb index f874536b89f..b87af5ca5dc 100644 --- a/spec/rubocop/cop/style/access_modifier_declarations_spec.rb +++ b/spec/rubocop/cop/style/access_modifier_declarations_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::AccessModifierDeclarations, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'always accepted' do |access_modifier| it 'accepts when #{access_modifier} is a hash literal value' do expect_no_offenses(<<~RUBY) diff --git a/spec/rubocop/cop/style/alias_spec.rb b/spec/rubocop/cop/style/alias_spec.rb index 0d55eef8308..9a5e5cef407 100644 --- a/spec/rubocop/cop/style/alias_spec.rb +++ b/spec/rubocop/cop/style/alias_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Alias, :config do - subject(:cop) { described_class.new(config) } - context 'when EnforcedStyle is prefer_alias_method' do let(:cop_config) { { 'EnforcedStyle' => 'prefer_alias_method' } } diff --git a/spec/rubocop/cop/style/ascii_comments_spec.rb b/spec/rubocop/cop/style/ascii_comments_spec.rb index 6d35689afe0..4b40990951b 100644 --- a/spec/rubocop/cop/style/ascii_comments_spec.rb +++ b/spec/rubocop/cop/style/ascii_comments_spec.rb @@ -22,8 +22,6 @@ end context 'when certain non-ascii chars are allowed', :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowedChars' => ['∂'] } } it 'accepts comment with allowed non-ascii chars' do diff --git a/spec/rubocop/cop/style/bare_percent_literals_spec.rb b/spec/rubocop/cop/style/bare_percent_literals_spec.rb index 57038a2170c..6faac031c05 100644 --- a/spec/rubocop/cop/style/bare_percent_literals_spec.rb +++ b/spec/rubocop/cop/style/bare_percent_literals_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::BarePercentLiterals, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'accepts other delimiters' do it 'accepts __FILE__' do expect_no_offenses('__FILE__') diff --git a/spec/rubocop/cop/style/block_delimiters_spec.rb b/spec/rubocop/cop/style/block_delimiters_spec.rb index 4e286316025..ece24e90d6c 100644 --- a/spec/rubocop/cop/style/block_delimiters_spec.rb +++ b/spec/rubocop/cop/style/block_delimiters_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::BlockDelimiters, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'syntactic styles' do it 'registers an offense for a single line block with do-end' do expect_offense(<<~RUBY) diff --git a/spec/rubocop/cop/style/class_and_module_children_spec.rb b/spec/rubocop/cop/style/class_and_module_children_spec.rb index ef3c87a2826..b11a6e6b3c8 100644 --- a/spec/rubocop/cop/style/class_and_module_children_spec.rb +++ b/spec/rubocop/cop/style/class_and_module_children_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ClassAndModuleChildren, :config do - subject(:cop) { described_class.new(config) } - context 'nested style' do let(:cop_config) { { 'EnforcedStyle' => 'nested' } } diff --git a/spec/rubocop/cop/style/class_check_spec.rb b/spec/rubocop/cop/style/class_check_spec.rb index 4c57b905428..79ce6810e60 100644 --- a/spec/rubocop/cop/style/class_check_spec.rb +++ b/spec/rubocop/cop/style/class_check_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ClassCheck, :config do - subject(:cop) { described_class.new(config) } - context 'when enforced style is is_a?' do let(:cop_config) { { 'EnforcedStyle' => 'is_a?' } } diff --git a/spec/rubocop/cop/style/command_literal_spec.rb b/spec/rubocop/cop/style/command_literal_spec.rb index c16425f4100..410e7c442e3 100644 --- a/spec/rubocop/cop/style/command_literal_spec.rb +++ b/spec/rubocop/cop/style/command_literal_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CommandLiteral, :config do - subject(:cop) { described_class.new(config) } - let(:config) do supported_styles = { 'SupportedStyles' => %w[backticks percent_x mixed] diff --git a/spec/rubocop/cop/style/comment_annotation_spec.rb b/spec/rubocop/cop/style/comment_annotation_spec.rb index ee8dc063adf..52ef21f3502 100644 --- a/spec/rubocop/cop/style/comment_annotation_spec.rb +++ b/spec/rubocop/cop/style/comment_annotation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::CommentAnnotation, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'Keywords' => %w[TODO FIXME OPTIMIZE HACK REVIEW] } end diff --git a/spec/rubocop/cop/style/copyright_spec.rb b/spec/rubocop/cop/style/copyright_spec.rb index 6cdbfcde172..aa90620121e 100644 --- a/spec/rubocop/cop/style/copyright_spec.rb +++ b/spec/rubocop/cop/style/copyright_spec.rb @@ -6,8 +6,6 @@ def expect_copyright_offense(cop, source) end RSpec.describe RuboCop::Cop::Style::Copyright, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'Notice' => 'Copyright (\(c\) )?2015 Acme Inc' } } it 'does not register an offense when the notice is present' do diff --git a/spec/rubocop/cop/style/date_time_spec.rb b/spec/rubocop/cop/style/date_time_spec.rb index 616ce9c8021..74bf41e2796 100644 --- a/spec/rubocop/cop/style/date_time_spec.rb +++ b/spec/rubocop/cop/style/date_time_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::DateTime, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowCoercion' => false } } it 'registers an offense when using DateTime for current time' do diff --git a/spec/rubocop/cop/style/dir_spec.rb b/spec/rubocop/cop/style/dir_spec.rb index 4d3fc392186..9919072903a 100644 --- a/spec/rubocop/cop/style/dir_spec.rb +++ b/spec/rubocop/cop/style/dir_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Dir, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'auto-correct' do |original, expected| it 'auto-corrects' do new_source = autocorrect_source(original) diff --git a/spec/rubocop/cop/style/documentation_method_spec.rb b/spec/rubocop/cop/style/documentation_method_spec.rb index a96d6835747..74223bf18fc 100644 --- a/spec/rubocop/cop/style/documentation_method_spec.rb +++ b/spec/rubocop/cop/style/documentation_method_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::DocumentationMethod, :config do - subject(:cop) { described_class.new(config) } - let(:require_for_non_public_methods) { false } let(:config) do diff --git a/spec/rubocop/cop/style/empty_method_spec.rb b/spec/rubocop/cop/style/empty_method_spec.rb index 957f6abe8ba..3d350c7abbc 100644 --- a/spec/rubocop/cop/style/empty_method_spec.rb +++ b/spec/rubocop/cop/style/empty_method_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::EmptyMethod, :config do - subject(:cop) { described_class.new(config) } - before do inspect_source(source) end diff --git a/spec/rubocop/cop/style/encoding_spec.rb b/spec/rubocop/cop/style/encoding_spec.rb index 0ca132215cf..51bd9c53ddc 100644 --- a/spec/rubocop/cop/style/encoding_spec.rb +++ b/spec/rubocop/cop/style/encoding_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Encoding, :config do - subject(:cop) { described_class.new(config) } - it 'registers no offense when no encoding present' do expect_no_offenses(<<~RUBY) def foo() end diff --git a/spec/rubocop/cop/style/expand_path_arguments_spec.rb b/spec/rubocop/cop/style/expand_path_arguments_spec.rb index 92854d3c225..841086ec59a 100644 --- a/spec/rubocop/cop/style/expand_path_arguments_spec.rb +++ b/spec/rubocop/cop/style/expand_path_arguments_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ExpandPathArguments, :config do - subject(:cop) { described_class.new(config) } - it "registers an offense when using `File.expand_path('..', __FILE__)`" do expect_offense(<<~RUBY) File.expand_path('..', __FILE__) diff --git a/spec/rubocop/cop/style/exponential_notation_spec.rb b/spec/rubocop/cop/style/exponential_notation_spec.rb index e29098371e2..3787f87a551 100644 --- a/spec/rubocop/cop/style/exponential_notation_spec.rb +++ b/spec/rubocop/cop/style/exponential_notation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ExponentialNotation, :config do - subject(:cop) { described_class.new(config) } - context 'EnforcedStyle is scientific' do let(:cop_config) { { 'EnforcedStyle' => 'scientific' } } diff --git a/spec/rubocop/cop/style/float_division_spec.rb b/spec/rubocop/cop/style/float_division_spec.rb index 47ee724ee4c..1e9e95061ee 100644 --- a/spec/rubocop/cop/style/float_division_spec.rb +++ b/spec/rubocop/cop/style/float_division_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FloatDivision, :config do - subject(:cop) { described_class.new(config) } - context 'EnforcedStyle is left_coerce' do let(:cop_config) { { 'EnforcedStyle' => 'left_coerce' } } diff --git a/spec/rubocop/cop/style/for_spec.rb b/spec/rubocop/cop/style/for_spec.rb index f40bf7c208b..90064fa12c4 100644 --- a/spec/rubocop/cop/style/for_spec.rb +++ b/spec/rubocop/cop/style/for_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::For, :config do - subject(:cop) { described_class.new(config) } - context 'when each is the enforced style' do let(:cop_config) { { 'EnforcedStyle' => 'each' } } diff --git a/spec/rubocop/cop/style/format_string_spec.rb b/spec/rubocop/cop/style/format_string_spec.rb index 613bf8a4fdd..c12e21a461b 100644 --- a/spec/rubocop/cop/style/format_string_spec.rb +++ b/spec/rubocop/cop/style/format_string_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FormatString, :config do - subject(:cop) { described_class.new(config) } - context 'when enforced style is sprintf' do let(:cop_config) { { 'EnforcedStyle' => 'sprintf' } } diff --git a/spec/rubocop/cop/style/format_string_token_spec.rb b/spec/rubocop/cop/style/format_string_token_spec.rb index 56bdb0ee8c3..20e51ad710d 100644 --- a/spec/rubocop/cop/style/format_string_token_spec.rb +++ b/spec/rubocop/cop/style/format_string_token_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FormatStringToken, :config do - subject(:cop) { described_class.new(config) } - let(:enforced_style) { :annotated } let(:cop_config) do diff --git a/spec/rubocop/cop/style/frozen_string_literal_comment_spec.rb b/spec/rubocop/cop/style/frozen_string_literal_comment_spec.rb index 5323a414027..1cc817c0e76 100644 --- a/spec/rubocop/cop/style/frozen_string_literal_comment_spec.rb +++ b/spec/rubocop/cop/style/frozen_string_literal_comment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::FrozenStringLiteralComment, :config do - subject(:cop) { described_class.new(config) } - context 'always' do let(:cop_config) do { 'Enabled' => true, diff --git a/spec/rubocop/cop/style/hash_syntax_spec.rb b/spec/rubocop/cop/style/hash_syntax_spec.rb index 56d781da2fa..c06800ce0f6 100644 --- a/spec/rubocop/cop/style/hash_syntax_spec.rb +++ b/spec/rubocop/cop/style/hash_syntax_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashSyntax, :config do - subject(:cop) { described_class.new(config) } - context 'configured to enforce ruby19 style' do context 'with SpaceAroundOperators enabled' do let(:config) do diff --git a/spec/rubocop/cop/style/hash_transform_keys_spec.rb b/spec/rubocop/cop/style/hash_transform_keys_spec.rb index a702eff24d8..5df5875c22c 100644 --- a/spec/rubocop/cop/style/hash_transform_keys_spec.rb +++ b/spec/rubocop/cop/style/hash_transform_keys_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashTransformKeys, :config do - subject(:cop) { described_class.new(config) } - context 'when using Ruby 2.5 or newer', :ruby25 do context 'with inline block' do it 'flags each_with_object when transform_keys could be used' do diff --git a/spec/rubocop/cop/style/hash_transform_values_spec.rb b/spec/rubocop/cop/style/hash_transform_values_spec.rb index 266ac53c4e4..24a4e46c8c2 100644 --- a/spec/rubocop/cop/style/hash_transform_values_spec.rb +++ b/spec/rubocop/cop/style/hash_transform_values_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::HashTransformValues, :config do - subject(:cop) { described_class.new(config) } - context 'with inline block' do it 'flags each_with_object when transform_values could be used' do expect_offense(<<~RUBY) diff --git a/spec/rubocop/cop/style/if_inside_else_spec.rb b/spec/rubocop/cop/style/if_inside_else_spec.rb index 21c0c36660e..abb0f0fa2fc 100644 --- a/spec/rubocop/cop/style/if_inside_else_spec.rb +++ b/spec/rubocop/cop/style/if_inside_else_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::IfInsideElse, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'AllowIfModifier' => false } end diff --git a/spec/rubocop/cop/style/ip_addresses_spec.rb b/spec/rubocop/cop/style/ip_addresses_spec.rb index ca7f6f71ac3..0f65503d88a 100644 --- a/spec/rubocop/cop/style/ip_addresses_spec.rb +++ b/spec/rubocop/cop/style/ip_addresses_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::IpAddresses, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { {} } it 'does not register an offense on an empty string' do diff --git a/spec/rubocop/cop/style/lambda_call_spec.rb b/spec/rubocop/cop/style/lambda_call_spec.rb index da5ca4222d9..55b174d87f2 100644 --- a/spec/rubocop/cop/style/lambda_call_spec.rb +++ b/spec/rubocop/cop/style/lambda_call_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::LambdaCall, :config do - subject(:cop) { described_class.new(config) } - context 'when style is set to call' do let(:cop_config) { { 'EnforcedStyle' => 'call' } } diff --git a/spec/rubocop/cop/style/lambda_spec.rb b/spec/rubocop/cop/style/lambda_spec.rb index a734511d76e..ade4aa7ac0f 100644 --- a/spec/rubocop/cop/style/lambda_spec.rb +++ b/spec/rubocop/cop/style/lambda_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Lambda, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'registers an offense' do |message| it 'registers an offense' do inspect_source(source) diff --git a/spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb b/spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb index a02234a4197..117dbc5abda 100644 --- a/spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb +++ b/spec/rubocop/cop/style/method_call_with_args_parentheses_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MethodCallWithArgsParentheses, :config do - subject(:cop) { described_class.new(config) } - context 'when EnforcedStyle is require_parentheses (default)' do let(:cop_config) do { 'IgnoredMethods' => %w[puts] } 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 2426f9854d0..f22258af931 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 @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MethodCallWithoutArgsParentheses, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'IgnoredMethods' => %w[s] } end diff --git a/spec/rubocop/cop/style/method_def_parentheses_spec.rb b/spec/rubocop/cop/style/method_def_parentheses_spec.rb index 7cfff0731a7..e98821540f3 100644 --- a/spec/rubocop/cop/style/method_def_parentheses_spec.rb +++ b/spec/rubocop/cop/style/method_def_parentheses_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MethodDefParentheses, :config do - subject(:cop) { described_class.new(config) } - context 'require_parentheses' do let(:cop_config) { { 'EnforcedStyle' => 'require_parentheses' } } diff --git a/spec/rubocop/cop/style/min_max_spec.rb b/spec/rubocop/cop/style/min_max_spec.rb index e00899b5d8d..75cb98ed7d4 100644 --- a/spec/rubocop/cop/style/min_max_spec.rb +++ b/spec/rubocop/cop/style/min_max_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MinMax, :config do - subject(:cop) { described_class.new(config) } - context 'with an array literal containing calls to `#min` and `#max`' do context 'when the expression stands alone' do it 'registers an offense if the receivers match' do diff --git a/spec/rubocop/cop/style/mixin_grouping_spec.rb b/spec/rubocop/cop/style/mixin_grouping_spec.rb index f300a8d20b9..d7d8ebd65ae 100644 --- a/spec/rubocop/cop/style/mixin_grouping_spec.rb +++ b/spec/rubocop/cop/style/mixin_grouping_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MixinGrouping, :config do - subject(:cop) { described_class.new(config) } - before do inspect_source(source) end diff --git a/spec/rubocop/cop/style/module_function_spec.rb b/spec/rubocop/cop/style/module_function_spec.rb index 5409f4606de..d4a08db10d9 100644 --- a/spec/rubocop/cop/style/module_function_spec.rb +++ b/spec/rubocop/cop/style/module_function_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ModuleFunction, :config do - subject(:cop) { described_class.new(config) } - context 'when enforced style is `module_function`' do let(:cop_config) { { 'EnforcedStyle' => 'module_function' } } diff --git a/spec/rubocop/cop/style/multiline_memoization_spec.rb b/spec/rubocop/cop/style/multiline_memoization_spec.rb index 92d75bfe0c6..6abe4f795b0 100644 --- a/spec/rubocop/cop/style/multiline_memoization_spec.rb +++ b/spec/rubocop/cop/style/multiline_memoization_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MultilineMemoization, :config do - subject(:cop) { described_class.new(config) } - let(:message) { 'Wrap multiline memoization blocks in `begin` and `end`.' } before do diff --git a/spec/rubocop/cop/style/multiline_method_signature_spec.rb b/spec/rubocop/cop/style/multiline_method_signature_spec.rb index d36262789da..0d9ff260d08 100644 --- a/spec/rubocop/cop/style/multiline_method_signature_spec.rb +++ b/spec/rubocop/cop/style/multiline_method_signature_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MultilineMethodSignature, :config do - subject(:cop) { described_class.new(config) } - context 'when arguments span multiple lines' do context 'when defining an instance method' do it 'registers an offense when `end` is on the following line' do diff --git a/spec/rubocop/cop/style/mutable_constant_spec.rb b/spec/rubocop/cop/style/mutable_constant_spec.rb index 79fd195c1b8..ca503ffae45 100644 --- a/spec/rubocop/cop/style/mutable_constant_spec.rb +++ b/spec/rubocop/cop/style/mutable_constant_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::MutableConstant, :config do - subject(:cop) { described_class.new(config) } - let(:prefix) { nil } shared_examples 'mutable objects' do |o| diff --git a/spec/rubocop/cop/style/next_spec.rb b/spec/rubocop/cop/style/next_spec.rb index 93859efc4d3..da3d54407e8 100644 --- a/spec/rubocop/cop/style/next_spec.rb +++ b/spec/rubocop/cop/style/next_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Next, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'MinBodyLength' => 1 } } shared_examples 'iterators' do |condition| diff --git a/spec/rubocop/cop/style/nil_comparison_spec.rb b/spec/rubocop/cop/style/nil_comparison_spec.rb index 283939f36f5..e7d2ded9005 100644 --- a/spec/rubocop/cop/style/nil_comparison_spec.rb +++ b/spec/rubocop/cop/style/nil_comparison_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NilComparison, :config do - subject(:cop) { described_class.new(config) } - context 'configured with predicate preferred' do let(:cop_config) { { 'EnforcedStyle' => 'predicate' } } diff --git a/spec/rubocop/cop/style/non_nil_check_spec.rb b/spec/rubocop/cop/style/non_nil_check_spec.rb index 2c273f2722b..b5f4b6e7176 100644 --- a/spec/rubocop/cop/style/non_nil_check_spec.rb +++ b/spec/rubocop/cop/style/non_nil_check_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NonNilCheck, :config do - subject(:cop) { described_class.new(config) } - context 'when not allowing semantic changes' do let(:cop_config) do { diff --git a/spec/rubocop/cop/style/not_spec.rb b/spec/rubocop/cop/style/not_spec.rb index adda6b7a921..bf6ad28c1a1 100644 --- a/spec/rubocop/cop/style/not_spec.rb +++ b/spec/rubocop/cop/style/not_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Not, :config do - subject(:cop) { described_class.new(config) } - it 'registers an offense for not' do expect_offense(<<~RUBY) not test diff --git a/spec/rubocop/cop/style/numeric_literal_prefix_spec.rb b/spec/rubocop/cop/style/numeric_literal_prefix_spec.rb index 61c25fbded5..4138e2014d1 100644 --- a/spec/rubocop/cop/style/numeric_literal_prefix_spec.rb +++ b/spec/rubocop/cop/style/numeric_literal_prefix_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NumericLiteralPrefix, :config do - subject(:cop) { described_class.new(config) } - context 'octal literals' do context 'when config is zero_with_o' do let(:cop_config) do diff --git a/spec/rubocop/cop/style/numeric_literals_spec.rb b/spec/rubocop/cop/style/numeric_literals_spec.rb index 17faa9d75b6..b1bee7e236c 100644 --- a/spec/rubocop/cop/style/numeric_literals_spec.rb +++ b/spec/rubocop/cop/style/numeric_literals_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NumericLiterals, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'MinDigits' => 5 } } it 'registers an offense for a long undelimited integer' do diff --git a/spec/rubocop/cop/style/numeric_predicate_spec.rb b/spec/rubocop/cop/style/numeric_predicate_spec.rb index 53d37a9d7ac..0943d945129 100644 --- a/spec/rubocop/cop/style/numeric_predicate_spec.rb +++ b/spec/rubocop/cop/style/numeric_predicate_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::NumericPredicate, :config do - subject(:cop) { described_class.new(config) } - before do inspect_source(source) end diff --git a/spec/rubocop/cop/style/option_hash_spec.rb b/spec/rubocop/cop/style/option_hash_spec.rb index e4546b37ddc..e63e5a7c30b 100644 --- a/spec/rubocop/cop/style/option_hash_spec.rb +++ b/spec/rubocop/cop/style/option_hash_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::OptionHash, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'SuspiciousParamNames' => suspicious_names } } let(:suspicious_names) { ['options'] } diff --git a/spec/rubocop/cop/style/parallel_assignment_spec.rb b/spec/rubocop/cop/style/parallel_assignment_spec.rb index 26ac08e7a64..c802f9728ab 100644 --- a/spec/rubocop/cop/style/parallel_assignment_spec.rb +++ b/spec/rubocop/cop/style/parallel_assignment_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ParallelAssignment, :config do - subject(:cop) { described_class.new(config) } - let(:config) do RuboCop::Config.new('Layout/IndentationWidth' => { 'Width' => 2 }) end diff --git a/spec/rubocop/cop/style/parentheses_around_condition_spec.rb b/spec/rubocop/cop/style/parentheses_around_condition_spec.rb index 953e1dc2bfb..a708b16ffc7 100644 --- a/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +++ b/spec/rubocop/cop/style/parentheses_around_condition_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::ParenthesesAroundCondition, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowSafeAssignment' => true } } it 'registers an offense for parentheses around condition' do diff --git a/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb b/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb index 852da34b970..82a63159cd3 100644 --- a/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb +++ b/spec/rubocop/cop/style/percent_literal_delimiters_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::PercentLiteralDelimiters, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'PreferredDelimiters' => { 'default' => '[]' } } end diff --git a/spec/rubocop/cop/style/percent_q_literals_spec.rb b/spec/rubocop/cop/style/percent_q_literals_spec.rb index 1d26cc3d974..2f77af9f684 100644 --- a/spec/rubocop/cop/style/percent_q_literals_spec.rb +++ b/spec/rubocop/cop/style/percent_q_literals_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::PercentQLiterals, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'accepts quote characters' do it 'accepts single quotes' do expect_no_offenses("'hi'") diff --git a/spec/rubocop/cop/style/preferred_hash_methods_spec.rb b/spec/rubocop/cop/style/preferred_hash_methods_spec.rb index 7c33c848e1e..57e45da598c 100644 --- a/spec/rubocop/cop/style/preferred_hash_methods_spec.rb +++ b/spec/rubocop/cop/style/preferred_hash_methods_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::PreferredHashMethods, :config do - subject(:cop) { described_class.new(config) } - context 'with enforced `short` style' do let(:cop_config) { { 'EnforcedStyle' => 'short' } } diff --git a/spec/rubocop/cop/style/raise_args_spec.rb b/spec/rubocop/cop/style/raise_args_spec.rb index 6fc5c0a4f1c..36094538a22 100644 --- a/spec/rubocop/cop/style/raise_args_spec.rb +++ b/spec/rubocop/cop/style/raise_args_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RaiseArgs, :config do - subject(:cop) { described_class.new(config) } - context 'when enforced style is compact' do let(:cop_config) { { 'EnforcedStyle' => 'compact' } } diff --git a/spec/rubocop/cop/style/redundant_begin_spec.rb b/spec/rubocop/cop/style/redundant_begin_spec.rb index 14f691e28d7..e8eda434982 100644 --- a/spec/rubocop/cop/style/redundant_begin_spec.rb +++ b/spec/rubocop/cop/style/redundant_begin_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantBegin, :config do - subject(:cop) { described_class.new(config) } - it 'reports an offense for single line def with redundant begin block' do expect_offense(<<~RUBY) def func; begin; x; y; rescue; z end; end diff --git a/spec/rubocop/cop/style/redundant_return_spec.rb b/spec/rubocop/cop/style/redundant_return_spec.rb index d3c06bd017c..eb0d74ebedf 100644 --- a/spec/rubocop/cop/style/redundant_return_spec.rb +++ b/spec/rubocop/cop/style/redundant_return_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RedundantReturn, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowMultipleReturnValues' => false } } it 'reports an offense for def with only a return' do diff --git a/spec/rubocop/cop/style/regexp_literal_spec.rb b/spec/rubocop/cop/style/regexp_literal_spec.rb index 5a4bdf51244..58382576f0d 100644 --- a/spec/rubocop/cop/style/regexp_literal_spec.rb +++ b/spec/rubocop/cop/style/regexp_literal_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RegexpLiteral, :config do - subject(:cop) { described_class.new(config) } - let(:config) do supported_styles = { 'SupportedStyles' => %w[slashes percent_r mixed] diff --git a/spec/rubocop/cop/style/rescue_standard_error_spec.rb b/spec/rubocop/cop/style/rescue_standard_error_spec.rb index 763aae2f392..e7d345497cd 100644 --- a/spec/rubocop/cop/style/rescue_standard_error_spec.rb +++ b/spec/rubocop/cop/style/rescue_standard_error_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::RescueStandardError, :config do - subject(:cop) { described_class.new(config) } - context 'implicit' do let(:cop_config) do { 'EnforcedStyle' => 'implicit', diff --git a/spec/rubocop/cop/style/safe_navigation_spec.rb b/spec/rubocop/cop/style/safe_navigation_spec.rb index c7139b56d7a..b2aa7470d1c 100644 --- a/spec/rubocop/cop/style/safe_navigation_spec.rb +++ b/spec/rubocop/cop/style/safe_navigation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SafeNavigation, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'ConvertCodeThatCanStartToReturnNil' => false } } let(:message) do diff --git a/spec/rubocop/cop/style/semicolon_spec.rb b/spec/rubocop/cop/style/semicolon_spec.rb index f05e9562507..1716a2fdac1 100644 --- a/spec/rubocop/cop/style/semicolon_spec.rb +++ b/spec/rubocop/cop/style/semicolon_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::Semicolon, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'AllowAsExpressionSeparator' => false } } it 'registers an offense for a single expression' do diff --git a/spec/rubocop/cop/style/signal_exception_spec.rb b/spec/rubocop/cop/style/signal_exception_spec.rb index d0408107276..a13e8a4ad1e 100644 --- a/spec/rubocop/cop/style/signal_exception_spec.rb +++ b/spec/rubocop/cop/style/signal_exception_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SignalException, :config do - subject(:cop) { described_class.new(config) } - context 'when enforced style is `semantic`' do let(:cop_config) { { 'EnforcedStyle' => 'semantic' } } diff --git a/spec/rubocop/cop/style/single_line_block_params_spec.rb b/spec/rubocop/cop/style/single_line_block_params_spec.rb index 0caf51fcdd9..27c01f8adc0 100644 --- a/spec/rubocop/cop/style/single_line_block_params_spec.rb +++ b/spec/rubocop/cop/style/single_line_block_params_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SingleLineBlockParams, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) do { 'Methods' => [{ 'reduce' => %w[a e] }, diff --git a/spec/rubocop/cop/style/slicing_with_range_spec.rb b/spec/rubocop/cop/style/slicing_with_range_spec.rb index 7395626a75b..2250eea4273 100644 --- a/spec/rubocop/cop/style/slicing_with_range_spec.rb +++ b/spec/rubocop/cop/style/slicing_with_range_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SlicingWithRange, :config do - subject(:cop) { described_class.new(config) } - context '<= Ruby 2.5', :ruby25 do it 'reports no offense for array slicing with -1' do expect_no_offenses(<<~RUBY) diff --git a/spec/rubocop/cop/style/special_global_vars_spec.rb b/spec/rubocop/cop/style/special_global_vars_spec.rb index 71d18a058b9..514770bda86 100644 --- a/spec/rubocop/cop/style/special_global_vars_spec.rb +++ b/spec/rubocop/cop/style/special_global_vars_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SpecialGlobalVars, :config do - subject(:cop) { described_class.new(config) } - context 'when style is use_english_names' do let(:cop_config) { { 'EnforcedStyle' => 'use_english_names' } } diff --git a/spec/rubocop/cop/style/stabby_lambda_parentheses_spec.rb b/spec/rubocop/cop/style/stabby_lambda_parentheses_spec.rb index 38a43aa6735..f3c743fd89a 100644 --- a/spec/rubocop/cop/style/stabby_lambda_parentheses_spec.rb +++ b/spec/rubocop/cop/style/stabby_lambda_parentheses_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StabbyLambdaParentheses, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'common' do it 'does not check the old lambda syntax' do expect_no_offenses('lambda(&:nil?)') diff --git a/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb b/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb index 49b1ac56921..beb92923c64 100644 --- a/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb +++ b/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StringLiteralsInInterpolation, :config do - subject(:cop) { described_class.new(config) } - context 'configured with single quotes preferred' do let(:cop_config) { { 'EnforcedStyle' => 'single_quotes' } } diff --git a/spec/rubocop/cop/style/string_literals_spec.rb b/spec/rubocop/cop/style/string_literals_spec.rb index 7e7e537f4ac..2cde4e12833 100644 --- a/spec/rubocop/cop/style/string_literals_spec.rb +++ b/spec/rubocop/cop/style/string_literals_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StringLiterals, :config do - subject(:cop) { described_class.new(config) } - context 'configured with single quotes preferred' do let(:cop_config) { { 'EnforcedStyle' => 'single_quotes' } } diff --git a/spec/rubocop/cop/style/string_methods_spec.rb b/spec/rubocop/cop/style/string_methods_spec.rb index 5eab9d5194c..49defd73020 100644 --- a/spec/rubocop/cop/style/string_methods_spec.rb +++ b/spec/rubocop/cop/style/string_methods_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::StringMethods, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'intern' => 'to_sym' } } it 'registers an offense' do diff --git a/spec/rubocop/cop/style/symbol_array_spec.rb b/spec/rubocop/cop/style/symbol_array_spec.rb index 71b92edeb3a..824ab84ce83 100644 --- a/spec/rubocop/cop/style/symbol_array_spec.rb +++ b/spec/rubocop/cop/style/symbol_array_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SymbolArray, :config do - subject(:cop) { described_class.new(config) } - before do # Reset data which is shared by all instances of SymbolArray described_class.largest_brackets = -Float::INFINITY diff --git a/spec/rubocop/cop/style/symbol_proc_spec.rb b/spec/rubocop/cop/style/symbol_proc_spec.rb index fce2850b8b6..0a6e6325c19 100644 --- a/spec/rubocop/cop/style/symbol_proc_spec.rb +++ b/spec/rubocop/cop/style/symbol_proc_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::SymbolProc, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { { 'IgnoredMethods' => %w[respond_to] } } it 'registers an offense for a block with parameterless method call on ' \ diff --git a/spec/rubocop/cop/style/ternary_parentheses_spec.rb b/spec/rubocop/cop/style/ternary_parentheses_spec.rb index bd911b6bdae..ff3ceb7c7f4 100644 --- a/spec/rubocop/cop/style/ternary_parentheses_spec.rb +++ b/spec/rubocop/cop/style/ternary_parentheses_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TernaryParentheses, :config do - subject(:cop) { described_class.new(config) } - before do inspect_source(source) end diff --git a/spec/rubocop/cop/style/trailing_comma_in_arguments_spec.rb b/spec/rubocop/cop/style/trailing_comma_in_arguments_spec.rb index 38db0aa7bac..86206e73080 100644 --- a/spec/rubocop/cop/style/trailing_comma_in_arguments_spec.rb +++ b/spec/rubocop/cop/style/trailing_comma_in_arguments_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TrailingCommaInArguments, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'single line lists' do |extra_info| it 'registers an offense for trailing comma in a method call' do expect_offense(<<~RUBY) diff --git a/spec/rubocop/cop/style/trailing_comma_in_array_literal_spec.rb b/spec/rubocop/cop/style/trailing_comma_in_array_literal_spec.rb index 255c7344135..3fd6e496076 100644 --- a/spec/rubocop/cop/style/trailing_comma_in_array_literal_spec.rb +++ b/spec/rubocop/cop/style/trailing_comma_in_array_literal_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TrailingCommaInArrayLiteral, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'single line lists' do |extra_info| it 'registers an offense for trailing comma' do expect_offense(<<~RUBY) diff --git a/spec/rubocop/cop/style/trailing_comma_in_hash_literal_spec.rb b/spec/rubocop/cop/style/trailing_comma_in_hash_literal_spec.rb index ed363271d65..86f74d73a68 100644 --- a/spec/rubocop/cop/style/trailing_comma_in_hash_literal_spec.rb +++ b/spec/rubocop/cop/style/trailing_comma_in_hash_literal_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TrailingCommaInHashLiteral, :config do - subject(:cop) { described_class.new(config) } - shared_examples 'single line lists' do |extra_info| it 'registers an offense for trailing comma in a literal' do expect_offense(<<~RUBY) diff --git a/spec/rubocop/cop/style/trivial_accessors_spec.rb b/spec/rubocop/cop/style/trivial_accessors_spec.rb index cb74224d759..6703fe6d97d 100644 --- a/spec/rubocop/cop/style/trivial_accessors_spec.rb +++ b/spec/rubocop/cop/style/trivial_accessors_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::TrivialAccessors, :config do - subject(:cop) { described_class.new(config) } - let(:cop_config) { {} } it 'registers an offense on instance reader' do diff --git a/spec/rubocop/cop/style/unpack_first_spec.rb b/spec/rubocop/cop/style/unpack_first_spec.rb index 61fefa05bc7..c39582ed17f 100644 --- a/spec/rubocop/cop/style/unpack_first_spec.rb +++ b/spec/rubocop/cop/style/unpack_first_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::UnpackFirst, :config do - subject(:cop) { described_class.new(config) } - context 'registers offense' do it 'when using `#unpack` with `#first`' do expect_offense(<<~RUBY) diff --git a/spec/rubocop/cop/style/word_array_spec.rb b/spec/rubocop/cop/style/word_array_spec.rb index c76ab4df261..240fa2ce8d7 100644 --- a/spec/rubocop/cop/style/word_array_spec.rb +++ b/spec/rubocop/cop/style/word_array_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::WordArray, :config do - subject(:cop) { described_class.new(config) } - before do # Reset data which is shared by all instances of WordArray described_class.largest_brackets = -Float::INFINITY diff --git a/spec/rubocop/cop/style/yoda_condition_spec.rb b/spec/rubocop/cop/style/yoda_condition_spec.rb index c2c58cf1bec..c41a9dbbe2f 100644 --- a/spec/rubocop/cop/style/yoda_condition_spec.rb +++ b/spec/rubocop/cop/style/yoda_condition_spec.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Style::YodaCondition, :config do - subject(:cop) { described_class.new(config) } - let(:error_message) { 'Reverse the order of the operands `%s`.' } shared_examples 'accepts' do |code|