Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/rubocop af part1 #1736

Merged
merged 10 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 4 additions & 106 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-09-02 09:39:29 UTC using RuboCop version 1.56.2.
# on 2023-09-06 13:00:58 UTC using RuboCop version 1.56.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# TODO - [LH] -> Aug '23 - 370 files inspected, 1110 offenses detected, 482 offenses autocorrectable
# TODO - [LH] -> Sep 6 '23 - 370 files inspected, 983 offenses detected, 368 offenses autocorrectable

# Offense count: 38
# This cop supports safe autocorrection (--autocorrect).
Expand All @@ -21,23 +22,12 @@ Layout/HashAlignment:
- 'lib/cucumber/formatter/ansicolor.rb'
- 'lib/cucumber/gherkin/formatter/ansi_escapes.rb'

# Offense count: 13
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
Layout/HeredocIndentation:
Exclude:
- 'features/lib/support/feature_factory.rb'
- 'lib/cucumber/cli/options.rb'
- 'lib/cucumber/cli/profile_loader.rb'
- 'spec/cucumber/cli/configuration_spec.rb'
- 'spec/cucumber/cli/profile_loader_spec.rb'
- 'spec/cucumber/formatter/pretty_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedMethods, AllowedPatterns.
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/cucumber/glue/step_definition_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Expand Down Expand Up @@ -89,22 +79,7 @@ RSpec/Capybara/FeatureMethods:
Exclude:
- 'spec/cucumber/filters/activate_steps_spec.rb'

# Offense count: 13
# This cop supports safe autocorrection (--autocorrect).
RSpec/ContextMethod:
Exclude:
- 'spec/cucumber/deprecate_spec.rb'
- 'spec/cucumber/formatter/backtrace_filter_spec.rb'
- 'spec/cucumber/formatter/http_io_spec.rb'
- 'spec/cucumber/formatter/query/hook_by_test_step_spec.rb'
- 'spec/cucumber/formatter/query/pickle_by_test_spec.rb'
- 'spec/cucumber/formatter/query/pickle_step_by_test_step_spec.rb'
- 'spec/cucumber/formatter/query/step_definitions_by_test_step_spec.rb'
- 'spec/cucumber/formatter/query/test_case_started_by_test_case_spec.rb'
- 'spec/cucumber/formatter/url_reporter_spec.rb'
- 'spec/cucumber/term/banner_spec.rb'

# Offense count: 98
# Offense count: 85
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand Down Expand Up @@ -135,63 +110,11 @@ RSpec/EmptyExampleGroup:
- 'spec/cucumber/filters/activate_steps_spec.rb'
- 'spec/cucumber/running_test_case_spec.rb'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowConsecutiveOneLiners.
RSpec/EmptyLineAfterExample:
Exclude:
- 'spec/cucumber/cli/options_spec.rb'
- 'spec/cucumber/formatter/pretty_spec.rb'
- 'spec/cucumber/multiline_argument/data_table_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
RSpec/EmptyLineAfterExampleGroup:
Exclude:
- 'spec/cucumber/formatter/rerun_spec.rb'

# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
RSpec/EmptyLineAfterFinalLet:
Exclude:
- 'spec/cucumber/cli/main_spec.rb'
- 'spec/cucumber/configuration_spec.rb'
- 'spec/cucumber/formatter/fail_fast_spec.rb'
- 'spec/cucumber/formatter/junit_spec.rb'
- 'spec/cucumber/formatter/pretty_spec.rb'
- 'spec/cucumber/hooks_spec.rb'
- 'spec/cucumber/rake/task_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowConsecutiveOneLiners.
RSpec/EmptyLineAfterHook:
Exclude:
- 'spec/cucumber/formatter/junit_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
RSpec/EmptyLineAfterSubject:
Exclude:
- 'spec/cucumber/filters/tag_limits/verifier_spec.rb'
- 'spec/cucumber/runtime/meta_message_builder_spec.rb'

# Offense count: 150
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 58

# Offense count: 51
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
# DisallowedExamples: works
RSpec/ExampleWording:
Exclude:
- 'spec/cucumber/cli/configuration_spec.rb'
- 'spec/cucumber/multiline_argument/data_table_spec.rb'
- 'spec/cucumber/project_initializer_spec.rb'
- 'spec/cucumber/rake/task_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
RSpec/ExpectActual:
Expand All @@ -218,13 +141,6 @@ RSpec/ExpectOutput:
RSpec/HookArgument:
Enabled: false

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
RSpec/HooksBeforeExamples:
Exclude:
- 'spec/cucumber/cli/configuration_spec.rb'
- 'spec/cucumber/formatter/interceptor_spec.rb'

# Offense count: 15
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Expand Down Expand Up @@ -291,17 +207,6 @@ RSpec/NamedSubject:
RSpec/NestedGroups:
Max: 6

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: not_to, to_not
RSpec/NotToNot:
Exclude:
- 'spec/cucumber/filters/gated_receiver_spec.rb'
- 'spec/cucumber/filters/tag_limits/verifier_spec.rb'
- 'spec/cucumber/glue/step_definition_spec.rb'
- 'spec/cucumber/multiline_argument/data_table_spec.rb'

# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers.
Expand Down Expand Up @@ -346,13 +251,6 @@ RSpec/ReturnFromStub:
- 'spec/cucumber/formatter/junit_spec.rb'
- 'spec/cucumber/glue/registry_and_more_spec.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
RSpec/ScatteredLet:
Exclude:
- 'spec/cucumber/glue/snippet_spec.rb'
- 'spec/cucumber/runtime/support_code_spec.rb'

# Offense count: 9
RSpec/StubbedMock:
Exclude:
Expand Down
14 changes: 7 additions & 7 deletions features/lib/support/feature_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

module FeatureFactory
def create_feature(name = generate_feature_name)
gherkin = <<-GHERKIN
Feature: #{name}
#{yield}
gherkin = <<~GHERKIN
Feature: #{name}
#{yield}
GHERKIN
write_file filename(name), gherkin
end

def create_feature_ja(name = generate_feature_name)
gherkin = <<-GHERKIN
# language: ja
機能: #{name}
#{yield}
gherkin = <<~GHERKIN
# language: ja
機能: #{name}
#{yield}
GHERKIN
write_file filename(name), gherkin
end
Expand Down
28 changes: 14 additions & 14 deletions spec/cucumber/cli/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ def reset_config
end

it 'parses ERB in cucumber.yml that makes uses nested ERB sessions' do
given_cucumber_yml_defined_as(<<ERB_YML)
<%= ERB.new({'standard' => '--require some_file'}.to_yaml).result %>
<%= ERB.new({'enhanced' => '--require other_file'}.to_yaml).result %>
ERB_YML
given_cucumber_yml_defined_as(<<~ERB_YML)
<%= ERB.new({'standard' => '--require some_file'}.to_yaml).result %>
<%= ERB.new({'enhanced' => '--require other_file'}.to_yaml).result %>
ERB_YML

config.parse!(%w[-p standard])

Expand All @@ -109,12 +109,12 @@ def reset_config
it 'provides a helpful error message when a specified profile does not exists in cucumber.yml' do
given_cucumber_yml_defined_as('default' => '--require from/yml', 'json_report' => '--format json')

expected_message = <<-END_OF_MESSAGE
Could not find profile: 'i_do_not_exist'
expected_message = <<~END_OF_MESSAGE
Could not find profile: 'i_do_not_exist'

Defined profiles in cucumber.yml:
* default
* json_report
Defined profiles in cucumber.yml:
* default
* json_report
END_OF_MESSAGE

expect { config.parse!(%w[--profile i_do_not_exist]) }.to raise_error(ProfileNotFound, expected_message)
Expand Down Expand Up @@ -357,6 +357,10 @@ def reset_config
Cucumber.use_full_backtrace = false
end

after do
Cucumber.use_full_backtrace = false
end

it 'shows full backtrace when --backtrace is present' do
Main.new(['--backtrace'])
begin
Expand All @@ -365,10 +369,6 @@ def reset_config
expect(e.backtrace[0]).not_to eq "#{__FILE__}:#{__LINE__ - 2}"
end
end

after do
Cucumber.use_full_backtrace = false
end
end

it 'accepts multiple --name options' do
Expand All @@ -385,7 +385,7 @@ def reset_config
expect(config.options[:name_regexps]).to include(/User signs up/)
end

it 'should allow specifying environment variables on the command line' do
it 'allows specifying environment variables on the command line' do
config.parse!(['foo=bar'])

expect(ENV['foo']).to eq 'bar'
Expand Down
1 change: 1 addition & 0 deletions spec/cucumber/cli/main_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Cli
let(:stdout) { StringIO.new }
let(:stderr) { StringIO.new }
let(:kernel) { double(:kernel) }

subject { Main.new(args, stdout, stderr, kernel) }

describe '#execute!' do
Expand Down
1 change: 1 addition & 0 deletions spec/cucumber/cli/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def with_env(name, value)
it "defaults the formatter to 'pretty' when not specified earlier" do
after_parsing('-o file.txt') { expect(options[:formats]).to eq [['pretty', {}, 'file.txt']] }
end

it 'sets the output for the formatter defined immediately before it' do
after_parsing('-f profile --out file.txt -f pretty -o file2.txt') do
expect(options[:formats]).to eq [['profile', {}, 'file.txt'], ['pretty', {}, 'file2.txt']]
Expand Down
8 changes: 4 additions & 4 deletions spec/cucumber/cli/profile_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def loader
end

it 'treats percent sign as ERB code block after YAML directive' do
yml = <<-HERE
---
% x = '--format "pretty" features/sync_imap_mailbox.feature:16:22'
default: <%= x %>
yml = <<~HERE
---
% x = '--format "pretty" features/sync_imap_mailbox.feature:16:22'
default: <%= x %>
HERE
given_cucumber_yml_defined_as yml
expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features/sync_imap_mailbox.feature:16:22']
Expand Down
1 change: 1 addition & 0 deletions spec/cucumber/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Cucumber

describe 'with custom user options' do
let(:user_options) { { autoload_code_paths: ['foo/bar/baz'] } }

subject { Configuration.new(user_options) }

it 'allows you to override the defaults' do
Expand Down
2 changes: 1 addition & 1 deletion spec/cucumber/deprecate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Cucumber::Deprecate
describe CliOption do
let(:error_stream) { double }

context '.deprecate' do
describe '.deprecate' do
it 'outputs a warning to the provided channel' do
allow(error_stream).to receive(:puts)
described_class.deprecate(error_stream, '--some-option', 'Please use --another-option instead', '1.2.3')
Expand Down
2 changes: 1 addition & 1 deletion spec/cucumber/filters/gated_receiver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
describe '#test_case' do
it 'does not immediately describe the test case to the receiver' do
test_cases.each do |test_case|
expect(test_case).to_not receive(:describe_to).with(receiver)
expect(test_case).not_to receive(:describe_to).with(receiver)
gated_receiver.test_case(test_case)
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/cucumber/filters/tag_limits/verifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
describe Cucumber::Filters::TagLimits::Verifier do
describe '#verify!' do
subject(:verifier) { Cucumber::Filters::TagLimits::Verifier.new(tag_limits) }

let(:test_case_index) { double(:test_case_index) }

context 'the tag counts exceed the tag limits' do
Expand Down Expand Up @@ -48,7 +49,7 @@
end

it 'does not raise an error' do
expect { verifier.verify!(test_case_index) }.to_not raise_error
expect { verifier.verify!(test_case_index) }.not_to raise_error
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/cucumber/formatter/backtrace_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module Cucumber
module Formatter
describe BacktraceFilter do
context '#exception' do
describe '#exception' do
before do
trace = %w[a b
_anything__/vendor/rails__anything_
Expand Down
1 change: 1 addition & 0 deletions spec/cucumber/formatter/fail_fast_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Cucumber::Formatter
include Cucumber::Core::Gherkin::Writer

let(:configuration) { Cucumber::Configuration.new }

before { FailFast.new(configuration) }

context 'failing scenario' do
Expand Down
2 changes: 1 addition & 1 deletion spec/cucumber/formatter/http_io_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def report(banner); end
end

describe CurlOptionParser do
context '.parse' do
describe '.parse' do
context 'when a simple URL is given' do
it 'returns the URL' do
url, = CurlOptionParser.parse('http://whatever.ltd')
Expand Down
Loading