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/manual rubocop fixes part3 #262

Merged
merged 19 commits into from
Sep 14, 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
20 changes: 20 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.5
bundler-cache: true
- run: bundle exec rubocop
33 changes: 12 additions & 21 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,33 @@ AllCops:
DisplayStyleGuide: true
NewCops: enable

# Disabling to allow people to install cucumber-core on older rubies
Gemspec/RequiredRubyVersion:
Enabled: false

# We do not support MFA at the moment with the new automated release process
Gemspec/RequireMFA:
Enabled: false

# Disabling for appveyor
Layout/EndOfLine:
Enabled: false

# Reviewed: please see PR-1022 for details on why this cop is disabled:
# https://github.com/cucumber/cucumber-ruby/pull/1022
Lint/AmbiguousOperator:
Enabled: false
# A line length of 200 covers most violations in the repo while still being
# a more up to date length given today's screen sizes
Layout/LineLength:
Max: 200

# We want to permit Exception rescuing in these two instances as they literally guard against the final fail chance
Lint/RescueException:
Exclude:
- lib/cucumber/core/test/action.rb
- lib/cucumber/core/test/around_hook.rb

# A line length of 200 covers most violations in the repo while still being
# a more up to date length given today's screen sizes
Layout/LineLength:
Max: 200
RSpec/ExampleLength:
CountAsOne: ['array', 'hash', 'heredoc']

# In most cases, being descriptive with parameter names helps a reader understand
# what the variable is for. In some cases, shorter names are sufficient.
Naming/MethodParameterName:
AllowedNames: _, e, n, v, id, io, gh, pr
# Stylistic preference for cucumber
RSpec/MessageSpies:
EnforcedStyle: receive

# We don't verbosely document this gem
Style/Documentation:
Enabled: false

# Slashes are by far the most used form of regex values in the project.
# Stylistic preference for cucumber
Style/RegexpLiteral:
EnforcedStyle: slashes
AllowInnerSlashes: true
132 changes: 35 additions & 97 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-09-08 16:36:48 UTC using RuboCop version 1.27.0.
# on 2023-09-13 11:52:02 UTC using RuboCop version 1.27.0.
# 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] Initial state -> 53 files inspected, 2221 offenses detected, 1663 offenses auto-correctable
# TODO: [LH] Part 1 iteration -> 53 files inspected, 1990 offenses detected, 1442 offenses auto-correctable
# TODO: [LH] Part 2 iteration -> 53 files inspected, 506 offenses detected, 163 offenses auto-correctable

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Expand Down Expand Up @@ -45,20 +46,26 @@ Layout/ExtraSpacing:
- 'cucumber-core.gemspec'
- 'spec/cucumber/core/test/runner_spec.rb'

# Offense count: 4
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/FirstArrayElementIndentation:
Exclude:
- 'spec/cucumber/core_spec.rb'

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Layout/HeredocIndentation:
Exclude:
- 'spec/cucumber/core/gherkin/writer_spec.rb'

# Offense count: 5
# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
Layout/LeadingCommentSpace:
Exclude:
- 'lib/cucumber/core/event_bus.rb'
- 'lib/cucumber/core/events.rb'
- 'lib/cucumber/core/test/result.rb'
- 'spec/cucumber/core/test/timer_spec.rb'

# Offense count: 5
Expand Down Expand Up @@ -95,10 +102,12 @@ Layout/SpaceAroundOperators:
Exclude:
- 'cucumber-core.gemspec'

# Offense count: 1
Lint/UselessAssignment:
# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'spec/cucumber/core/test/filters/locations_filter_spec.rb'
- 'spec/cucumber/core/test/result_spec.rb'

# Offense count: 3
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Expand All @@ -109,34 +118,23 @@ Metrics/AbcSize:
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 400
Max: 410

# Offense count: 6
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 30

# Offense count: 6
# Offense count: 5
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 402
Max: 412

# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 7

# Offense count: 2
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'spec/**/*'
- 'lib/cucumber/core/event_bus.rb'

# Offense count: 4
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: PreferredName.
Expand All @@ -145,7 +143,7 @@ Naming/RescuedExceptionsVariableName:
- 'lib/cucumber/core/test/action.rb'
- 'lib/cucumber/core/test/around_hook.rb'

# Offense count: 65
# Offense count: 62
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnabledMethods.
RSpec/Capybara/FeatureMethods:
Expand All @@ -154,9 +152,10 @@ RSpec/Capybara/FeatureMethods:
- 'spec/cucumber/core/filter_spec.rb'
- 'spec/cucumber/core/gherkin/parser_spec.rb'
- 'spec/cucumber/core/gherkin/writer_spec.rb'
- 'spec/cucumber/core/test/case_spec.rb'
- 'spec/cucumber/core_spec.rb'

# Offense count: 47
# Offense count: 45
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Expand All @@ -175,10 +174,10 @@ RSpec/ContextWording:
- 'spec/cucumber/core/test/result_spec.rb'
- 'spec/cucumber/core/test/runner_spec.rb'

# Offense count: 57
# Offense count: 38
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 48
Max: 33

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Expand All @@ -195,11 +194,6 @@ RSpec/ExpectActual:
- 'spec/cucumber/core/test/doc_string_spec.rb'

# Offense count: 2
RSpec/ExpectInHook:
Exclude:
- 'spec/cucumber/core/report/summary_spec.rb'

# Offense count: 4
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, each, example
Expand All @@ -209,22 +203,12 @@ RSpec/HookArgument:
- 'spec/cucumber/core/test/data_table_spec.rb'

# Offense count: 1
RSpec/IdenticalEqualityAssertion:
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/cucumber/core/test/data_table_spec.rb'

# Offense count: 1
RSpec/IteratedExpectation:
Exclude:
- 'spec/cucumber/core/test/case_spec.rb'

# Offense count: 92
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive
- 'spec/cucumber/core/test/runner_spec.rb'

# Offense count: 27
# Offense count: 25
RSpec/MissingExampleGroupArgument:
Exclude:
- 'spec/cucumber/core/compiler_spec.rb'
Expand All @@ -235,39 +219,24 @@ RSpec/MissingExampleGroupArgument:
- 'spec/cucumber/core/test/filters/locations_filter_spec.rb'
- 'spec/cucumber/core_spec.rb'

# Offense count: 92
# Offense count: 83
RSpec/MultipleExpectations:
Max: 8
Max: 6

# Offense count: 55
# Offense count: 56
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 19
Max: 20

# Offense count: 5
# Offense count: 13
RSpec/NestedGroups:
Max: 5

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: not_to, to_not
RSpec/NotToNot:
Exclude:
- 'spec/cucumber/core/test/result_spec.rb'

# Offense count: 2
RSpec/RepeatedDescription:
Exclude:
- 'spec/cucumber/core/gherkin/parser_spec.rb'

# Offense count: 18
# Offense count: 8
RSpec/RepeatedExample:
Exclude:
- 'spec/cucumber/core/filter_spec.rb'
- 'spec/cucumber/core/gherkin/parser_spec.rb'
- 'spec/cucumber/core/test/filters/locations_filter_spec.rb'
- 'spec/cucumber/core/test/result_spec.rb'
- 'spec/cucumber/core_spec.rb'

# Offense count: 1
Expand All @@ -276,20 +245,11 @@ RSpec/ScatteredLet:
Exclude:
- 'spec/cucumber/core/test/filters/locations_filter_spec.rb'

# Offense count: 14
RSpec/StubbedMock:
Exclude:
- 'spec/cucumber/core/report/summary_spec.rb'
- 'spec/cucumber/core/test/result_spec.rb'
- 'spec/cucumber/core/test/runner_spec.rb'

# Offense count: 6
# Offense count: 1
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/cucumber/core/compiler_spec.rb'
- 'spec/cucumber/core/test/result_spec.rb'
- 'spec/cucumber/core/test/step_spec.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
Expand Down Expand Up @@ -370,12 +330,6 @@ Style/MethodCallWithoutArgsParentheses:
Exclude:
- 'lib/cucumber/core/test/timer.rb'

# Offense count: 2
Style/MissingRespondToMissing:
Exclude:
- 'lib/cucumber/core/event_bus.rb'
- 'lib/cucumber/core/test/result.rb'

# Offense count: 1
Style/MultilineBlockChain:
Exclude:
Expand All @@ -391,13 +345,6 @@ Style/NumericPredicate:
- 'lib/cucumber/core/event.rb'
- 'lib/cucumber/core/test/result.rb'

# Offense count: 6
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/cucumber/core/test/result.rb'

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
Style/ParallelAssignment:
Expand All @@ -421,15 +368,6 @@ Style/RaiseArgs:
- 'lib/cucumber/core/test/case.rb'
- 'spec/cucumber/core/test/runner_spec.rb'

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- 'lib/cucumber/core/test/location.rb'
- 'spec/cucumber/core/test/location_spec.rb'

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowAsExpressionSeparator.
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
## [Unreleased]
### Changed
- Now using a 2-tiered changelog to avoid any bugs when using polyglot-release
- More refactoring of the repo by fixing up a bunch of manual rubocop offenses (See PR for details)
([#259](https://github.com/cucumber/cucumber-ruby-core/pull/259) [#262](https://github.com/cucumber/cucumber-ruby-core/pull/262))
- In all `Summary` and `Result` classes, changed the `strict` argument into a keyword argument.
See upgrading notes for [13.0.0.md](upgrading_notes/13.0.0.md#upgrading-to-1300)
([#261](https://github.com/cucumber/cucumber-ruby-core/pull/261))

## [12.0.0] - 2023-09-06
### Changed
- Update gherkin and messages minimum dependencies
- Added in new rubocop sub-gems for testing, pinning versions where appropriate
- Removed all redundant / incorrect rubocop config overrides (Placed in TODO file)
- Began to refactor the repo by initially fixing up a bunch of rubocop auto-fix offenses (See PRs for details)
([#257](https://github.com/cucumber/cucumber-ruby-core/pull/257) [#258](https://github.com/cucumber/cucumber-ruby-core/pull/258))

### Removed
- Remove support for ruby 2.4 and below. 2.5 or higher is required now
Expand Down
Loading