From e6d19af57242c97e1ffda4bcea545122422690b0 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Wed, 5 Feb 2025 13:47:33 +0000 Subject: [PATCH 01/15] Update rubocop by introducing all other sub-gems --- ruby/.rubocop.yml | 16 +++++++--------- ruby/cucumber-gherkin.gemspec | 4 ++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml index 80ee7446e..b75aa6386 100644 --- a/ruby/.rubocop.yml +++ b/ruby/.rubocop.yml @@ -4,12 +4,11 @@ inherit_mode: merge: - Exclude -#require: -# - rubocop-packaging -# - rubocop-performance -# - rubocop-rails -# - rubocop-rake -# - rubocop-rspec +require: + - rubocop-packaging + - rubocop-performance + - rubocop-rake + - rubocop-rspec AllCops: TargetRubyVersion: 3.0 @@ -33,9 +32,8 @@ Style/RegexpLiteral: EnforcedStyle: slashes AllowInnerSlashes: true -## Disabled until rubocop-rspec is introduced -#RSpec/MessageSpies: -# EnforcedStyle: receive +RSpec/MessageSpies: + EnforcedStyle: receive # Hack to make rubocop not flag these (We need to re-analyse these later on) Naming/MethodName: diff --git a/ruby/cucumber-gherkin.gemspec b/ruby/cucumber-gherkin.gemspec index a1212d7f9..5cafef39e 100644 --- a/ruby/cucumber-gherkin.gemspec +++ b/ruby/cucumber-gherkin.gemspec @@ -28,6 +28,10 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '~> 13.1' s.add_development_dependency 'rspec', '~> 3.13' s.add_development_dependency 'rubocop', '~> 1.71.0' + s.add_development_dependency 'rubocop-rspec', '~> 2.6.0' + s.add_development_dependency 'rubocop-packaging', '~> 0.5.0' + s.add_development_dependency 'rubocop-performance', '~> 1.5.1' + s.add_development_dependency 'rubocop-rake', '~> 0.6.0' s.executables = %w[gherkin-ruby gherkin] s.files = Dir['README.md', 'LICENSE', 'lib/**/*'] From 09dffed786374d91537931ef5e3a836c27600fce Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Wed, 5 Feb 2025 13:49:43 +0000 Subject: [PATCH 02/15] Regen the TODO file for new gem introduction --- ruby/.rubocop_todo.yml | 101 +++++++++++++++++++++++++++++++++-------- 1 file changed, 81 insertions(+), 20 deletions(-) diff --git a/ruby/.rubocop_todo.yml b/ruby/.rubocop_todo.yml index 483adf388..362d866eb 100644 --- a/ruby/.rubocop_todo.yml +++ b/ruby/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-11-05 17:37:25 UTC using RuboCop version 1.26.1. +# on 2025-02-05 13:48:33 UTC using RuboCop version 1.26.1. # 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 @@ -13,14 +13,23 @@ # Pass 2 - September 2024 (Reconciled issues) - 27 files inspected, 2823 offenses detected, 2491 offenses auto-correctable # Pass 3 - October 2024 (Minor tweaks for python fix) - 27 files inspected, 2831 offenses detected, 2472 offenses auto-correctable # Pass 4 - November 2024 (Minor tweaks ready for 30.0.1) - 27 files inspected, 2725 offenses detected, 2444 offenses auto-correctable +# Pass 5 - February 2025 (Introduce all rubocop subgems) - 27 files inspected, 2301 offenses detected, 2060 offenses auto-correctable -# Offense count: 63 +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'cucumber-gherkin.gemspec' + +# Offense count: 55 # This cop supports safe auto-correction (--auto-correct). Layout/EmptyLineAfterGuardClause: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 51 +# Offense count: 43 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: @@ -92,7 +101,7 @@ Lint/Loop: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 59 +# Offense count: 51 # Configuration parameters: IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: Max: 120 @@ -111,14 +120,14 @@ Metrics/BlockNesting: # Offense count: 4 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 3693 + Max: 3087 -# Offense count: 44 +# Offense count: 36 # Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: - Max: 51 + Max: 43 -# Offense count: 72 +# Offense count: 64 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. Metrics/MethodLength: Max: 141 @@ -129,7 +138,7 @@ Metrics/ParameterLists: Max: 7 MaxOptionalParameters: 5 -# Offense count: 44 +# Offense count: 36 # Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: Max: 18 @@ -141,11 +150,63 @@ Naming/AccessorMethodName: - 'lib/gherkin/parser.rb' - 'lib/gherkin/token_formatter_builder.rb' -# Offense count: 29 -# Configuration parameters: IgnoredPatterns. -# SupportedStyles: snake_case, camelCase -Naming/MethodName: - EnforcedStyle: snake_case +# Offense count: 1 +Performance/FixedSize: + Exclude: + - 'lib/gherkin/token_matcher.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +Performance/RedundantBlockCall: + Exclude: + - 'lib/gherkin/parser.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Performance/RegexpMatch: + Exclude: + - 'lib/gherkin/gherkin_line.rb' + +# Offense count: 3 +# This cop supports safe auto-correction (--auto-correct). +RSpec/ContextMethod: + Exclude: + - 'spec/gherkin/gherkin_line_spec.rb' + - 'spec/gherkin/stream/parser_message_stream_spec.rb' + +# Offense count: 5 +# Configuration parameters: Prefixes. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/gherkin/gherkin_line_spec.rb' + - 'spec/gherkin/query_spec.rb' + - 'spec/gherkin/stream/parser_message_stream_spec.rb' + +# Offense count: 7 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: SkipBlocks, EnforcedStyle. +# SupportedStyles: described_class, explicit +RSpec/DescribedClass: + Exclude: + - 'spec/gherkin/dialect_spec.rb' + - 'spec/gherkin/gherkin_spec.rb' + - 'spec/gherkin/query_spec.rb' + - 'spec/gherkin/stream/parser_message_stream_spec.rb' + +# Offense count: 6 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 10 + +# Offense count: 1 +RSpec/MultipleExpectations: + Max: 2 + +# Offense count: 8 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 12 # Offense count: 2 # This cop supports unsafe auto-correction (--auto-correct-all). @@ -206,7 +267,7 @@ Style/NumericPredicate: - 'lib/gherkin/ast_builder.rb' - 'lib/gherkin/gherkin_line.rb' -# Offense count: 54 +# Offense count: 46 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. Style/ParenthesesAroundCondition: @@ -230,7 +291,7 @@ Style/RaiseArgs: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 50 +# Offense count: 42 # This cop supports safe auto-correction (--auto-correct). Style/RedundantParentheses: Exclude: @@ -242,7 +303,7 @@ Style/RedundantRegexpEscape: Exclude: - 'spec/gherkin/stream/parser_message_stream_spec.rb' -# Offense count: 66 +# Offense count: 58 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: @@ -255,7 +316,7 @@ Style/RedundantSelf: Exclude: - 'lib/gherkin/gherkin_line.rb' -# Offense count: 1620 +# Offense count: 1342 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: @@ -277,7 +338,7 @@ Style/SlicingWithRange: - 'lib/gherkin/ast_builder.rb' - 'lib/gherkin/gherkin_line.rb' -# Offense count: 58 +# Offense count: 46 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: AllowModifier. Style/SoleNestedConditional: @@ -302,7 +363,7 @@ Style/StringConcatenation: - 'lib/gherkin/gherkin_line.rb' - 'lib/gherkin/pickles/compiler.rb' -# Offense count: 411 +# Offense count: 343 # This cop supports safe auto-correction (--auto-correct). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes From 47ccd11f8c87a2ab5c930f3795b12737f586c220 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Wed, 5 Feb 2025 14:06:35 +0000 Subject: [PATCH 03/15] Add entry in rubocop issue tracker for problem; --- ruby/.rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml index b75aa6386..e071e5b49 100644 --- a/ruby/.rubocop.yml +++ b/ruby/.rubocop.yml @@ -35,6 +35,6 @@ Style/RegexpLiteral: RSpec/MessageSpies: EnforcedStyle: receive -# Hack to make rubocop not flag these (We need to re-analyse these later on) +# Bug in rubocop auto-gen config: https://github.com/rubocop/rubocop/issues/13795 Naming/MethodName: Enabled: false From bfb00190ad1db537bddc734645abb69770e3ea8b Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 6 Feb 2025 11:55:13 +0000 Subject: [PATCH 04/15] Regenerate TODO with a downgraded version of rubocop and introduced subgems --- ruby/.rubocop.yml | 8 +- ruby/.rubocop_todo.yml | 137 ++++++++++++++++++++-------------- ruby/cucumber-gherkin.gemspec | 2 +- 3 files changed, 85 insertions(+), 62 deletions(-) diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml index e071e5b49..3147f024f 100644 --- a/ruby/.rubocop.yml +++ b/ruby/.rubocop.yml @@ -34,7 +34,7 @@ Style/RegexpLiteral: RSpec/MessageSpies: EnforcedStyle: receive - -# Bug in rubocop auto-gen config: https://github.com/rubocop/rubocop/issues/13795 -Naming/MethodName: - Enabled: false +# +## Bug in rubocop auto-gen config: https://github.com/rubocop/rubocop/issues/13795 +#Naming/MethodName: +# Enabled: false diff --git a/ruby/.rubocop_todo.yml b/ruby/.rubocop_todo.yml index 362d866eb..dc7dfaab3 100644 --- a/ruby/.rubocop_todo.yml +++ b/ruby/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-02-05 13:48:33 UTC using RuboCop version 1.26.1. +# on 2025-02-06 11:53:47 UTC using RuboCop version 1.40.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 @@ -16,7 +16,7 @@ # Pass 5 - February 2025 (Introduce all rubocop subgems) - 27 files inspected, 2301 offenses detected, 2060 offenses auto-correctable # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. # Include: **/*.gemspec Gemspec/OrderedDependencies: @@ -24,27 +24,27 @@ Gemspec/OrderedDependencies: - 'cucumber-gherkin.gemspec' # Offense count: 55 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterGuardClause: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 43 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 3 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: Exclude: - 'lib/gherkin/parser.rb' - 'spec/gherkin/stream/parser_message_stream_spec.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only Layout/EmptyLinesAroundClassBody: @@ -52,7 +52,7 @@ Layout/EmptyLinesAroundClassBody: - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines Layout/EmptyLinesAroundModuleBody: @@ -60,14 +60,22 @@ Layout/EmptyLinesAroundModuleBody: - 'lib/gherkin/parser.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: leading, trailing +Layout/LineContinuationLeadingSpace: + Exclude: + - 'spec/gherkin/stream/parser_message_stream_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). Layout/SpaceAfterComma: Exclude: - 'bin/gherkin-generate-tokens' - 'lib/gherkin/gherkin_line.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space Layout/SpaceAroundEqualsInParameterDefault: @@ -75,7 +83,7 @@ Layout/SpaceAroundEqualsInParameterDefault: - 'lib/gherkin/parser.rb' # Offense count: 4 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. # SupportedStylesForExponentOperator: space, no_space Layout/SpaceAroundOperators: @@ -83,7 +91,7 @@ Layout/SpaceAroundOperators: - 'lib/gherkin/parser.rb' # Offense count: 14 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: space, compact, no_space Layout/SpaceInsideParens: @@ -96,19 +104,19 @@ Lint/LiteralAsCondition: - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/Loop: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 51 -# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes. Metrics/AbcSize: Max: 120 # Offense count: 8 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. -# IgnoredMethods: refine +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. +# AllowedMethods: refine Metrics/BlockLength: Max: 165 @@ -123,12 +131,12 @@ Metrics/ClassLength: Max: 3087 # Offense count: 36 -# Configuration parameters: IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. Metrics/CyclomaticComplexity: Max: 43 # Offense count: 64 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. Metrics/MethodLength: Max: 141 @@ -139,7 +147,7 @@ Metrics/ParameterLists: MaxOptionalParameters: 5 # Offense count: 36 -# Configuration parameters: IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. Metrics/PerceivedComplexity: Max: 18 @@ -150,25 +158,31 @@ Naming/AccessorMethodName: - 'lib/gherkin/parser.rb' - 'lib/gherkin/token_formatter_builder.rb' +# Offense count: 29 +# Configuration parameters: AllowedPatterns, IgnoredPatterns. +# SupportedStyles: snake_case, camelCase +Naming/MethodName: + EnforcedStyle: snake_case + # Offense count: 1 Performance/FixedSize: Exclude: - 'lib/gherkin/token_matcher.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Performance/RedundantBlockCall: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Performance/RegexpMatch: Exclude: - 'lib/gherkin/gherkin_line.rb' # Offense count: 3 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). RSpec/ContextMethod: Exclude: - 'spec/gherkin/gherkin_line_spec.rb' @@ -184,7 +198,7 @@ RSpec/ContextWording: - 'spec/gherkin/stream/parser_message_stream_spec.rb' # Offense count: 7 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit RSpec/DescribedClass: @@ -209,20 +223,20 @@ RSpec/MultipleMemoizedHelpers: Max: 12 # Offense count: 2 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). Style/CaseLikeIf: Exclude: - 'lib/gherkin/gherkin_line.rb' - 'lib/gherkin/token_matcher.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Style/DefWithParentheses: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent Style/FormatString: @@ -230,13 +244,14 @@ Style/FormatString: - 'lib/gherkin/token_formatter_builder.rb' # Offense count: 8 -# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns, IgnoredMethods. # SupportedStyles: annotated, template, unannotated Style/FormatStringToken: EnforcedStyle: unannotated # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: @@ -244,14 +259,14 @@ Style/FrozenStringLiteralComment: - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: IgnoredMethods. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. Style/MethodCallWithoutArgsParentheses: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: literals, strict Style/MutableConstant: @@ -259,8 +274,8 @@ Style/MutableConstant: - 'lib/gherkin/parser.rb' # Offense count: 3 -# This cop supports unsafe auto-correction (--auto-correct-all). -# Configuration parameters: EnforcedStyle, IgnoredMethods. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: @@ -268,14 +283,14 @@ Style/NumericPredicate: - 'lib/gherkin/gherkin_line.rb' # Offense count: 46 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. Style/ParenthesesAroundCondition: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 3 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: short, verbose Style/PreferredHashMethods: @@ -284,7 +299,7 @@ Style/PreferredHashMethods: - 'lib/gherkin/token_matcher.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, AllowedCompactTypes. # SupportedStyles: compact, exploded Style/RaiseArgs: @@ -292,39 +307,47 @@ Style/RaiseArgs: - 'lib/gherkin/parser.rb' # Offense count: 42 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Style/RedundantParentheses: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 4 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Style/RedundantRegexpEscape: Exclude: - 'spec/gherkin/stream/parser_message_stream_spec.rb' # Offense count: 58 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). Style/RedundantSelf: Exclude: - 'lib/gherkin/gherkin_line.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/gherkin/ast_builder.rb' + # Offense count: 1342 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: only_raise, only_fail, semantic Style/SignalException: @@ -332,29 +355,29 @@ Style/SignalException: - 'lib/gherkin/token_scanner.rb' # Offense count: 3 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: Exclude: - 'lib/gherkin/ast_builder.rb' - 'lib/gherkin/gherkin_line.rb' # Offense count: 46 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowModifier. Style/SoleNestedConditional: Exclude: - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: RequireEnglish, EnforcedStyle. -# SupportedStyles: use_perl_names, use_english_names +# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names Style/SpecialGlobalVars: Exclude: - 'Rakefile' # Offense count: 5 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: Exclude: @@ -364,7 +387,7 @@ Style/StringConcatenation: - 'lib/gherkin/pickles/compiler.rb' # Offense count: 343 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: @@ -377,7 +400,7 @@ Style/StringLiterals: - 'spec/gherkin/stream/parser_message_stream_spec.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: single_quotes, double_quotes Style/StringLiteralsInInterpolation: @@ -385,23 +408,23 @@ Style/StringLiteralsInInterpolation: - 'lib/gherkin/errors.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). Style/StructInheritance: Exclude: - 'lib/gherkin/gherkin_line.rb' - 'lib/gherkin/token.rb' # Offense count: 3 -# This cop supports unsafe auto-correction (--auto-correct-all). -# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods. -# IgnoredMethods: respond_to, define_method +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowComments. +# AllowedMethods: define_method Style/SymbolProc: Exclude: - 'lib/gherkin/ast_builder.rb' - 'lib/gherkin/parser.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, AllowSafeAssignment. # SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex Style/TernaryParentheses: @@ -409,7 +432,7 @@ Style/TernaryParentheses: - 'lib/gherkin/errors.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInArguments: @@ -417,7 +440,7 @@ Style/TrailingCommaInArguments: - 'lib/gherkin/ast_builder.rb' # Offense count: 2 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInArrayLiteral: @@ -426,7 +449,7 @@ Style/TrailingCommaInArrayLiteral: - 'lib/gherkin/query.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInHashLiteral: @@ -434,7 +457,7 @@ Style/TrailingCommaInHashLiteral: - 'lib/gherkin/pickles/compiler.rb' # Offense count: 1 -# This cop supports unsafe auto-correction (--auto-correct-all). +# This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: Exclude: - 'lib/gherkin/gherkin_line.rb' diff --git a/ruby/cucumber-gherkin.gemspec b/ruby/cucumber-gherkin.gemspec index 5cafef39e..9e2d32cc2 100644 --- a/ruby/cucumber-gherkin.gemspec +++ b/ruby/cucumber-gherkin.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '~> 13.1' s.add_development_dependency 'rspec', '~> 3.13' - s.add_development_dependency 'rubocop', '~> 1.71.0' + s.add_development_dependency 'rubocop', '~> 1.40.0' s.add_development_dependency 'rubocop-rspec', '~> 2.6.0' s.add_development_dependency 'rubocop-packaging', '~> 0.5.0' s.add_development_dependency 'rubocop-performance', '~> 1.5.1' From ad15b75d7ba2e41c2ea668647c4caded3ec64b55 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 6 Feb 2025 11:55:36 +0000 Subject: [PATCH 05/15] Reintroduce local override for MethodName whilst bug is still prevalent --- ruby/.rubocop.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml index 3147f024f..e071e5b49 100644 --- a/ruby/.rubocop.yml +++ b/ruby/.rubocop.yml @@ -34,7 +34,7 @@ Style/RegexpLiteral: RSpec/MessageSpies: EnforcedStyle: receive -# -## Bug in rubocop auto-gen config: https://github.com/rubocop/rubocop/issues/13795 -#Naming/MethodName: -# Enabled: false + +# Bug in rubocop auto-gen config: https://github.com/rubocop/rubocop/issues/13795 +Naming/MethodName: + Enabled: false From f9ccd7efb9e046bb899ead1fb75846d108202c76 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 6 Feb 2025 11:57:56 +0000 Subject: [PATCH 06/15] Partial interim update of rubocop subgems to try alleviate deprecations / warnings --- ruby/cucumber-gherkin.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ruby/cucumber-gherkin.gemspec b/ruby/cucumber-gherkin.gemspec index 9e2d32cc2..2fc9df136 100644 --- a/ruby/cucumber-gherkin.gemspec +++ b/ruby/cucumber-gherkin.gemspec @@ -28,9 +28,9 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '~> 13.1' s.add_development_dependency 'rspec', '~> 3.13' s.add_development_dependency 'rubocop', '~> 1.40.0' - s.add_development_dependency 'rubocop-rspec', '~> 2.6.0' - s.add_development_dependency 'rubocop-packaging', '~> 0.5.0' - s.add_development_dependency 'rubocop-performance', '~> 1.5.1' + s.add_development_dependency 'rubocop-rspec', '~> 2.15.0' + s.add_development_dependency 'rubocop-packaging', '~> 0.5.2' + s.add_development_dependency 'rubocop-performance', '~> 1.13.1' s.add_development_dependency 'rubocop-rake', '~> 0.6.0' s.executables = %w[gherkin-ruby gherkin] From 23f8b160eae8abbf0cc6042e980b66ab922c6a9a Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 6 Feb 2025 12:00:51 +0000 Subject: [PATCH 07/15] Update rubocop gems to all latest --- ruby/cucumber-gherkin.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ruby/cucumber-gherkin.gemspec b/ruby/cucumber-gherkin.gemspec index 2fc9df136..56f8ff28d 100644 --- a/ruby/cucumber-gherkin.gemspec +++ b/ruby/cucumber-gherkin.gemspec @@ -27,10 +27,10 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '~> 13.1' s.add_development_dependency 'rspec', '~> 3.13' - s.add_development_dependency 'rubocop', '~> 1.40.0' - s.add_development_dependency 'rubocop-rspec', '~> 2.15.0' + s.add_development_dependency 'rubocop', '~> 1.71.2' + s.add_development_dependency 'rubocop-rspec', '~> 3.4.0' s.add_development_dependency 'rubocop-packaging', '~> 0.5.2' - s.add_development_dependency 'rubocop-performance', '~> 1.13.1' + s.add_development_dependency 'rubocop-performance', '~> 1.23.1' s.add_development_dependency 'rubocop-rake', '~> 0.6.0' s.executables = %w[gherkin-ruby gherkin] From 04a402841c22893f68e026967706fc9fb76085e3 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 6 Feb 2025 12:01:40 +0000 Subject: [PATCH 08/15] Final TODO regeneration - added a few more ignores whilst gems are being updated --- ruby/.rubocop_todo.yml | 101 +++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 38 deletions(-) diff --git a/ruby/.rubocop_todo.yml b/ruby/.rubocop_todo.yml index dc7dfaab3..723d9a7a7 100644 --- a/ruby/.rubocop_todo.yml +++ b/ruby/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-02-06 11:53:47 UTC using RuboCop version 1.40.0. +# on 2025-02-06 12:01:10 UTC using RuboCop version 1.71.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 @@ -13,7 +13,23 @@ # Pass 2 - September 2024 (Reconciled issues) - 27 files inspected, 2823 offenses detected, 2491 offenses auto-correctable # Pass 3 - October 2024 (Minor tweaks for python fix) - 27 files inspected, 2831 offenses detected, 2472 offenses auto-correctable # Pass 4 - November 2024 (Minor tweaks ready for 30.0.1) - 27 files inspected, 2725 offenses detected, 2444 offenses auto-correctable -# Pass 5 - February 2025 (Introduce all rubocop subgems) - 27 files inspected, 2301 offenses detected, 2060 offenses auto-correctable +# Pass 5 - February 2025 (Introduce all rubocop subgems) - 27 files inspected, 2316 offenses detected, 2074 offenses autocorrectable + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/AddRuntimeDependency: + Exclude: + - 'cucumber-gherkin.gemspec' + +# Offense count: 7 +# Configuration parameters: EnforcedStyle, AllowedGems, Include. +# SupportedStyles: Gemfile, gems.rb, gemspec +# Include: **/*.gemspec, **/Gemfile, **/gems.rb +Gemspec/DevelopmentDependencies: + Exclude: + - 'cucumber-gherkin.gemspec' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -31,7 +47,7 @@ Layout/EmptyLineAfterGuardClause: # Offense count: 43 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: Exclude: - 'lib/gherkin/parser.rb' @@ -60,8 +76,8 @@ Layout/EmptyLinesAroundModuleBody: - 'lib/gherkin/parser.rb' # Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect, EnforcedStyle. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: leading, trailing Layout/LineContinuationLeadingSpace: Exclude: @@ -84,8 +100,9 @@ Layout/SpaceAroundEqualsInParameterDefault: # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. # SupportedStylesForExponentOperator: space, no_space +# SupportedStylesForRationalLiterals: space, no_space Layout/SpaceAroundOperators: Exclude: - 'lib/gherkin/parser.rb' @@ -110,20 +127,15 @@ Lint/Loop: - 'lib/gherkin/parser.rb' # Offense count: 51 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes. +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 120 -# Offense count: 8 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. +# Offense count: 2 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: - Max: 165 - -# Offense count: 1 -# Configuration parameters: CountBlocks. -Metrics/BlockNesting: - Max: 4 + Max: 42 # Offense count: 4 # Configuration parameters: CountComments, CountAsOne. @@ -131,12 +143,12 @@ Metrics/ClassLength: Max: 3087 # Offense count: 36 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 43 # Offense count: 64 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 141 @@ -147,7 +159,7 @@ Metrics/ParameterLists: MaxOptionalParameters: 5 # Offense count: 36 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 18 @@ -158,17 +170,23 @@ Naming/AccessorMethodName: - 'lib/gherkin/parser.rb' - 'lib/gherkin/token_formatter_builder.rb' -# Offense count: 29 -# Configuration parameters: AllowedPatterns, IgnoredPatterns. -# SupportedStyles: snake_case, camelCase -Naming/MethodName: - EnforcedStyle: snake_case +# Offense count: 1 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'lib/gherkin/gherkin_line.rb' # Offense count: 1 Performance/FixedSize: Exclude: - 'lib/gherkin/token_matcher.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Performance/MapCompact: + Exclude: + - 'spec/gherkin/query_spec.rb' + # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Performance/RedundantBlockCall: @@ -189,7 +207,7 @@ RSpec/ContextMethod: - 'spec/gherkin/stream/parser_message_stream_spec.rb' # Offense count: 5 -# Configuration parameters: Prefixes. +# Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: @@ -199,7 +217,7 @@ RSpec/ContextWording: # Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: SkipBlocks, EnforcedStyle. +# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit RSpec/DescribedClass: Exclude: @@ -222,13 +240,6 @@ RSpec/MultipleExpectations: RSpec/MultipleMemoizedHelpers: Max: 12 -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/CaseLikeIf: - Exclude: - - 'lib/gherkin/gherkin_line.rb' - - 'lib/gherkin/token_matcher.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/DefWithParentheses: @@ -245,7 +256,7 @@ Style/FormatString: # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. # SupportedStyles: annotated, template, unannotated Style/FormatStringToken: EnforcedStyle: unannotated @@ -260,7 +271,7 @@ Style/FrozenStringLiteralComment: # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: AllowedMethods, AllowedPatterns. Style/MethodCallWithoutArgsParentheses: Exclude: - 'lib/gherkin/parser.rb' @@ -275,7 +286,7 @@ Style/MutableConstant: # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods. +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: @@ -299,14 +310,14 @@ Style/PreferredHashMethods: - 'lib/gherkin/token_matcher.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedCompactTypes. # SupportedStyles: compact, exploded Style/RaiseArgs: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 42 +# Offense count: 46 # This cop supports safe autocorrection (--autocorrect). Style/RedundantParentheses: Exclude: @@ -331,6 +342,14 @@ Style/RedundantSelf: Exclude: - 'lib/gherkin/gherkin_line.rb' +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantSelfAssignmentBranch: + Exclude: + - 'lib/gherkin/ast_builder.rb' + - 'lib/gherkin/parser.rb' + - 'lib/gherkin/pickles/compiler.rb' + # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. @@ -414,9 +433,15 @@ Style/StructInheritance: - 'lib/gherkin/gherkin_line.rb' - 'lib/gherkin/token.rb' +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/SuperWithArgsParentheses: + Exclude: + - 'lib/gherkin/errors.rb' + # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowComments. +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. # AllowedMethods: define_method Style/SymbolProc: Exclude: From 8414e4d6402fa3324cd623489b7f2b1c81432d40 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Thu, 6 Feb 2025 12:44:02 +0000 Subject: [PATCH 09/15] Add changelog for this change and the next PR --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b07b7b19..ee2b8403f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt ### Changed - [.NET] Reduce NuGet size by only targeting .NET Standard 2.0 - [.NET] Changed some types from class to struct, removed IGherkinLine interface and changes some functions from Array to Enumerable +- [Ruby] Update minimum ruby requirement from 3.0 to 3.2 +- [Ruby] Introduce rubocop subgems to facilitate optimisations ### Fixed - [.NET] Fix NuGet package generation From 8353610a599e9961e12725cf57e1b02475f99530 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Sat, 8 Feb 2025 15:49:33 +0000 Subject: [PATCH 10/15] Fix up ruby 3.2 cop offenses --- ruby/lib/gherkin/parser.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruby/lib/gherkin/parser.rb b/ruby/lib/gherkin/parser.rb index eb3ed9203..a6bdd461e 100644 --- a/ruby/lib/gherkin/parser.rb +++ b/ruby/lib/gherkin/parser.rb @@ -3254,8 +3254,8 @@ def lookahead1(context, current_token) private - def handle_ast_error(context, &action) - handle_external_error(context, true, &action) + def handle_ast_error(context, &) + handle_external_error(context, true, &) end def handle_external_error(context, default_value, &action) From d645af6c879a6c717c22ddd634be2a45163f3f1a Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Sat, 8 Feb 2025 15:51:22 +0000 Subject: [PATCH 11/15] Fix up some spacing autofix cops and add note about fix for heredoc required --- ruby/spec/gherkin/stream/parser_message_stream_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ruby/spec/gherkin/stream/parser_message_stream_spec.rb b/ruby/spec/gherkin/stream/parser_message_stream_spec.rb index ccf3db715..7031c6586 100644 --- a/ruby/spec/gherkin/stream/parser_message_stream_spec.rb +++ b/ruby/spec/gherkin/stream/parser_message_stream_spec.rb @@ -3,10 +3,11 @@ module Gherkin module Stream describe ParserMessageStream do + # TODO: Fix this up into a heredoc LH - Feb '25 let(:feature_content) do - "Feature: my feature\n" \ - " Scenario: a scenario\n" \ - " Given some context" + "Feature: my feature\n " \ + "Scenario: a scenario\n " \ + "Given some context" end let(:source_feature) do @@ -45,7 +46,6 @@ module Stream end end - context 'when set' do let(:id_generator) { double } let(:options) do From bab61deed2908d55d4ed08bb3869d9e761a43ffa Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Sat, 8 Feb 2025 15:51:57 +0000 Subject: [PATCH 12/15] AF: Layout/SpaceAfterComma --- ruby/bin/gherkin-generate-tokens | 2 +- ruby/lib/gherkin/gherkin_line.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ruby/bin/gherkin-generate-tokens b/ruby/bin/gherkin-generate-tokens index c2e79fc29..3b6e3bfbd 100755 --- a/ruby/bin/gherkin-generate-tokens +++ b/ruby/bin/gherkin-generate-tokens @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'../lib')) +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib')) require 'gherkin/parser' require 'gherkin/token_formatter_builder' diff --git a/ruby/lib/gherkin/gherkin_line.rb b/ruby/lib/gherkin/gherkin_line.rb index 16a99e1c6..44a43a203 100644 --- a/ruby/lib/gherkin/gherkin_line.rb +++ b/ruby/lib/gherkin/gherkin_line.rb @@ -85,7 +85,7 @@ def split_table_cells(row) end def tags - uncommented_line = @trimmed_line_text.split(/\s#/,2)[0] + uncommented_line = @trimmed_line_text.split(/\s#/, 2)[0] column = @indent + 1 items = uncommented_line.split('@') From 239c4fbe9b5e7bf1bf59242d6e6b342c71ab4fe5 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Sat, 8 Feb 2025 16:02:56 +0000 Subject: [PATCH 13/15] Fix up RSpec context --- ruby/spec/gherkin/gherkin_line_spec.rb | 4 ++-- ruby/spec/gherkin/query_spec.rb | 2 +- ruby/spec/gherkin/stream/parser_message_stream_spec.rb | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ruby/spec/gherkin/gherkin_line_spec.rb b/ruby/spec/gherkin/gherkin_line_spec.rb index 8485e298e..2a8d63d57 100644 --- a/ruby/spec/gherkin/gherkin_line_spec.rb +++ b/ruby/spec/gherkin/gherkin_line_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Gherkin::GherkinLine do - context '#tags' do + describe '#tags' do def tags(line) Gherkin::GherkinLine.new(line, 12).tags.map(&:text) end @@ -11,7 +11,7 @@ def tags(line) end end - context '#table_cells' do + describe '#table_cells' do def cells_text(line) Gherkin::GherkinLine.new(line, 12).table_cells.map(&:text) end diff --git a/ruby/spec/gherkin/query_spec.rb b/ruby/spec/gherkin/query_spec.rb index 95b3bb843..8686618fa 100644 --- a/ruby/spec/gherkin/query_spec.rb +++ b/ruby/spec/gherkin/query_spec.rb @@ -107,7 +107,7 @@ def find_message_by_attribute(messages, attribute) end end - context 'in a scenario outline' do + context 'with a scenario outline' do let(:scenario) { scenarios.last } it 'provides the feature and background locations of a given scenario outline node id' do diff --git a/ruby/spec/gherkin/stream/parser_message_stream_spec.rb b/ruby/spec/gherkin/stream/parser_message_stream_spec.rb index 7031c6586..6e15bedb3 100644 --- a/ruby/spec/gherkin/stream/parser_message_stream_spec.rb +++ b/ruby/spec/gherkin/stream/parser_message_stream_spec.rb @@ -30,8 +30,8 @@ module Stream let(:scenario_id) { gherkin_document.feature.children.first.scenario.id } - context '#messages' do - it "raises an exception on second iteration" do + describe '#messages' do + it "raises an exception on the second iteration" do messages = ParserMessageStream.new([], [source_feature], options).messages expect { messages.map(&:to_s) }.not_to raise_exception @@ -39,7 +39,7 @@ module Stream end end - context 'options.id_generator' do + describe '#options.id_generator' do context 'when not set' do it 'generates random UUIDs' do expect(scenario_id).to match(/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/) @@ -57,6 +57,7 @@ module Stream it 'uses the generator instance to produce the IDs' do allow(id_generator).to receive(:new_id).and_return('some-random-id') + expect(scenario_id).to eq('some-random-id') end end From c7a76bd6c88ce3fd00cf9666578462cc61a83eac Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Sat, 8 Feb 2025 16:04:31 +0000 Subject: [PATCH 14/15] Fix up a couple of minor autofixes for the razor template that generates the parser --- ruby/gherkin-ruby.razor | 3 ++- ruby/lib/gherkin/parser.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ruby/gherkin-ruby.razor b/ruby/gherkin-ruby.razor index f648f623a..46dc0dacb 100644 --- a/ruby/gherkin-ruby.razor +++ b/ruby/gherkin-ruby.razor @@ -25,6 +25,8 @@ return @state.Id} @helper MatchToken(TokenType tokenType) {match_@(tokenType)(context, token)} +# frozen_string_literal: true + # This file is generated. Do not edit! Edit gherkin-ruby.razor instead. require_relative 'ast_builder' require_relative 'token_matcher' @@ -32,7 +34,6 @@ require_relative 'token_scanner' require_relative 'errors' module Gherkin - RULE_TYPE = [ :None, @foreach(var rule in Model.RuleSet.Where(r => !r.TempRule)) diff --git a/ruby/lib/gherkin/parser.rb b/ruby/lib/gherkin/parser.rb index a6bdd461e..29beae145 100644 --- a/ruby/lib/gherkin/parser.rb +++ b/ruby/lib/gherkin/parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file is generated. Do not edit! Edit gherkin-ruby.razor instead. require_relative 'ast_builder' require_relative 'token_matcher' @@ -5,7 +7,6 @@ require_relative 'errors' module Gherkin - RULE_TYPE = [ :None, :_EOF, # #EOF From 5e43588cef22992997cd8440980d3b2e70b2d5b7 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Mon, 10 Feb 2025 15:17:18 +0000 Subject: [PATCH 15/15] Manually fix one of the parser issues --- ruby/gherkin-ruby.razor | 5 ++--- ruby/lib/gherkin/parser.rb | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ruby/gherkin-ruby.razor b/ruby/gherkin-ruby.razor index 46dc0dacb..a5bfd1cee 100644 --- a/ruby/gherkin-ruby.razor +++ b/ruby/gherkin-ruby.razor @@ -202,8 +202,8 @@ module Gherkin private - def handle_ast_error(context, &action) - handle_external_error(context, true, &action) + def handle_ast_error(context, &) + handle_external_error(context, true, &) end def handle_external_error(context, default_value, &action) @@ -218,6 +218,5 @@ module Gherkin end default_value end - end end diff --git a/ruby/lib/gherkin/parser.rb b/ruby/lib/gherkin/parser.rb index 29beae145..ce66d6132 100644 --- a/ruby/lib/gherkin/parser.rb +++ b/ruby/lib/gherkin/parser.rb @@ -3271,6 +3271,5 @@ def handle_external_error(context, default_value, &action) end default_value end - end end