Skip to content

Commit

Permalink
Refactor/manual cops part1 (#1739)
Browse files Browse the repository at this point in the history
* Partial manual fix of RSpec/ContextWording

* Partial example length fixes

* Fix up some ExampleLength issues

* Improve ExampleLength to treat all long objects as single line counts

* Partial fix of multiple expectations

* Fix global var offenses

* Fix: RSpec/IteratedExpectation

* Configure setting for message spy cop

* Add some notes about stylistic preferences and re-enable some disabled cops to be introduced to auto-gen file

* Update auto-gen-config file

* Remove a redundant spec in step match search

* Re-gen the auto-gen-config file

* Fix missing param by replacing with a double

* Fix up line number references in json spec
  • Loading branch information
luke-hill committed Sep 12, 2023
1 parent 4c69bee commit 8e519a5
Show file tree
Hide file tree
Showing 22 changed files with 589 additions and 601 deletions.
25 changes: 12 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ AllCops:
Layout/EndOfLine:
EnforcedStyle: lf

# 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

# Reviewed: Formatters put trailing spaces after things like 'Feature: '
# In pretty_spec.rb & progress_spec.rb offences look false as the trailing spaces are in fact multiline string literals
Layout/TrailingWhitespace:
Expand Down Expand Up @@ -71,10 +75,6 @@ Metrics/ClassLength:
# TODO: Manually added! - be careful with regenning the file - this needs a fix
- lib/cucumber/formatter/pretty.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

# TODO: [LH] - Initial 10% reduction done Aug '23 - Further reductions should happen as/when we fix a bunch of the todo
Metrics/ModuleLength:
Max: 135
Expand Down Expand Up @@ -102,8 +102,6 @@ Naming/AsciiIdentifiers:
# For the most part, the project is solid on naming. There are though, a few
# cases where the cop doesn't need to catch.
Naming/MethodName:
EnforcedStyle: snake_case
Enabled: true
Exclude:
- 'examples/i18n/ar/lib/calculator.rb'
- 'examples/i18n/he/lib/calculator.rb'
Expand All @@ -129,20 +127,21 @@ Naming/VariableNumber:
Exclude:
- 'examples/i18n/**/*'

# This cop throws errors when parsing a lot of the repo's code, possibly due
# to splat issues?
Style/AccessModifierDeclarations:
Enabled: false
RSpec/ExampleLength:
CountAsOne: ['array', 'hash', 'heredoc']

# Stylistic preference for cucumber
RSpec/MessageSpies:
EnforcedStyle: receive

# Stylistic preference for cucumber
Style/Documentation:
Enabled: false

Style/FormatStringToken:
EnforcedStyle: annotated

Style/StderrPuts:
Enabled: false

# Stylistic preference for cucumber
Style/RegexpLiteral:
EnforcedStyle: slashes
AllowInnerSlashes: true
136 changes: 83 additions & 53 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-09-07 08:42:40 UTC using RuboCop version 1.56.2.
# on 2023-09-12 16:42:15 UTC using RuboCop version 1.56.3.
# 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
# TODO - [LH] -> Sep 11 '23 - 370 files inspected, 825 offenses detected, 387 offenses autocorrectable

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleAlignWith.
# SupportedStylesAlignWith: either, start_of_block, start_of_line
Layout/BlockAlignment:
Exclude:
- 'spec/cucumber/formatter/fail_fast_spec.rb'

# Offense count: 17
# This cop supports safe autocorrection (--autocorrect).
Layout/ClosingHeredocIndentation:
Exclude:
- 'spec/cucumber/cli/profile_loader_spec.rb'
- 'spec/cucumber/formatter/json_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLines:
Exclude:
- 'spec/cucumber/formatter/fail_fast_spec.rb'

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

# Offense count: 2
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Layout/HeredocIndentation:
Exclude:
- 'lib/cucumber/cli/options.rb'
- 'lib/cucumber/cli/profile_loader.rb'
- 'spec/cucumber/cli/profile_loader_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Layout/IndentationConsistency:
Exclude:
- 'spec/cucumber/formatter/fail_fast_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Width, AllowedPatterns.
Layout/IndentationWidth:
Exclude:
- 'spec/cucumber/formatter/fail_fast_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Expand All @@ -41,12 +79,6 @@ Lint/SuppressedException:
Exclude:
- 'lib/cucumber/rake/task.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/UselessAssignment:
Exclude:
- 'spec/cucumber/formatter/interceptor_spec.rb'

# Offense count: 9
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Expand Down Expand Up @@ -77,11 +109,19 @@ RSpec/Capybara/FeatureMethods:
Exclude:
- 'spec/cucumber/filters/activate_steps_spec.rb'

# Offense count: 85
# Offense count: 15
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Enabled: false
Exclude:
- 'spec/cucumber/cli/options_spec.rb'
- 'spec/cucumber/cli/rerun_spec.rb'
- 'spec/cucumber/configuration_spec.rb'
- 'spec/cucumber/filters/tag_limits_spec.rb'
- 'spec/cucumber/formatter/http_io_spec.rb'
- 'spec/cucumber/formatter/junit_spec.rb'
- 'spec/cucumber/formatter/publish_banner_printer_spec.rb'
- 'spec/cucumber/glue/step_definition_spec.rb'

# Offense count: 1
# Configuration parameters: IgnoredMetadata.
Expand All @@ -94,15 +134,15 @@ RSpec/DescribeClass:
- '**/spec/views/**/*'
- 'spec/cck/cck_spec.rb'

# Offense count: 18
# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/cucumber/formatter/interceptor_spec.rb'
- 'spec/cucumber/cli/profile_loader_spec.rb'
- 'spec/cucumber/formatter/json_spec.rb'
- 'spec/cucumber/multiline_argument/data_table_spec.rb'
- 'spec/cucumber/runtime/support_code_spec.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Expand All @@ -119,12 +159,12 @@ RSpec/EmptyLineAfterFinalLet:
- 'spec/cucumber/configuration_spec.rb'
- 'spec/cucumber/hooks_spec.rb'

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

# Offense count: 4
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
# DisallowedExamples: works
Expand All @@ -146,54 +186,32 @@ RSpec/ExpectInHook:
- 'spec/cucumber/multiline_argument/data_table_spec.rb'
- 'spec/cucumber/runtime/meta_message_builder_spec.rb'

# Offense count: 9
# Offense count: 6
RSpec/ExpectOutput:
Exclude:
- 'spec/cucumber/formatter/interceptor_spec.rb'

# Offense count: 71
# Offense count: 62
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, each, example
RSpec/HookArgument:
Enabled: false

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

# Offense count: 15
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/cucumber/formatter/http_io_spec.rb'

# Offense count: 1
RSpec/IteratedExpectation:
Exclude:
- 'spec/cucumber/filters/gated_receiver_spec.rb'

# Offense count: 59
# Offense count: 6
# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Exclude:
- 'spec/cucumber/cli/configuration_spec.rb'
- 'spec/cucumber/cli/main_spec.rb'
- 'spec/cucumber/cli/options_spec.rb'
- 'spec/cucumber/filters/activate_steps_spec.rb'
- 'spec/cucumber/filters/gated_receiver_spec.rb'
- 'spec/cucumber/filters/retry_spec.rb'
- 'spec/cucumber/filters/tag_limits_spec.rb'
- 'spec/cucumber/formatter/interceptor_spec.rb'
- 'spec/cucumber/glue/registry_and_more_spec.rb'
- 'spec/cucumber/glue/step_definition_spec.rb'
- 'spec/cucumber/project_initializer_spec.rb'
- 'spec/cucumber/runtime/meta_message_builder_spec.rb'
- 'spec/cucumber/step_match_search_spec.rb'
- 'spec/cucumber/world/pending_spec.rb'
- 'spec/cucumber/deprecate_spec.rb'
- 'spec/cucumber/formatter/http_io_spec.rb'
- 'spec/cucumber/runtime/hooks_examples.rb'

# Offense count: 15
RSpec/MissingExampleGroupArgument:
Expand All @@ -202,11 +220,11 @@ RSpec/MissingExampleGroupArgument:
- 'spec/cucumber/formatter/fail_fast_spec.rb'
- 'spec/cucumber/formatter/rerun_spec.rb'

# Offense count: 90
# Offense count: 87
RSpec/MultipleExpectations:
Max: 8

# Offense count: 37
# Offense count: 38
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 15
Expand Down Expand Up @@ -254,10 +272,9 @@ RSpec/RepeatedExample:
- 'spec/cucumber/formatter/rerun_spec.rb'
- 'spec/cucumber/world/pending_spec.rb'

# Offense count: 4
# Offense count: 2
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/cucumber/formatter/interceptor_spec.rb'
- 'spec/cucumber/glue/proto_world_spec.rb'

# Offense count: 31
Expand All @@ -283,12 +300,6 @@ RSpec/ScatteredLet:
Exclude:
- 'spec/cucumber/runtime/support_code_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
RSpec/ScatteredSetup:
Exclude:
- 'spec/cucumber/formatter/interceptor_spec.rb'

# Offense count: 9
RSpec/StubbedMock:
Exclude:
Expand Down Expand Up @@ -334,3 +345,22 @@ Style/ClassAndModuleChildren:
Style/ClassVars:
Exclude:
- 'spec/cucumber/glue/step_definition_spec.rb'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
Style/StderrPuts:
Exclude:
- 'examples/i18n/Rakefile'
- 'lib/cucumber/cli/main.rb'
- 'lib/cucumber/deprecate.rb'
- 'lib/cucumber/formatter/unicode.rb'
- 'lib/cucumber/rake/task.rb'
- 'spec/cucumber/formatter/interceptor_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'spec/cucumber/cli/options_spec.rb'
Loading

0 comments on commit 8e519a5

Please sign in to comment.