diff --git a/CHANGELOG.md b/CHANGELOG.md index d483d9c4a..8e1ffa11d 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 - [JavaScript] BREAKING CHANGE: Update supported Node.js versions to 18, 20, 22 and 23 ([#365](https://github.com/cucumber/gherkin/pull/365)) ### Fixed diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml index 6b21ceeb1..2ffa3a657 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.2 @@ -33,10 +32,9 @@ 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) +# 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 483adf388..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 2024-11-05 17:37:25 UTC using RuboCop version 1.26.1. +# 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,29 +13,54 @@ # 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, 2316 offenses detected, 2074 offenses autocorrectable -# Offense count: 63 -# This cop supports safe auto-correction (--auto-correct). +# 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). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'cucumber-gherkin.gemspec' + +# Offense count: 55 +# This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterGuardClause: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 51 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +# Offense count: 43 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, 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: @@ -43,7 +68,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: @@ -51,14 +76,22 @@ Layout/EmptyLinesAroundModuleBody: - '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: 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: @@ -66,15 +99,16 @@ Layout/SpaceAroundEqualsInParameterDefault: - 'lib/gherkin/parser.rb' # Offense count: 4 -# This cop supports safe auto-correction (--auto-correct). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. # SupportedStylesForExponentOperator: space, no_space +# SupportedStylesForRationalLiterals: space, no_space Layout/SpaceAroundOperators: Exclude: - '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: @@ -87,39 +121,34 @@ 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: 59 -# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +# Offense count: 51 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 120 -# Offense count: 8 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. -# IgnoredMethods: refine +# 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. Metrics/ClassLength: - Max: 3693 + Max: 3087 -# Offense count: 44 -# Configuration parameters: IgnoredMethods. +# Offense count: 36 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: - Max: 51 + Max: 43 -# Offense count: 72 -# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# Offense count: 64 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 141 @@ -129,8 +158,8 @@ Metrics/ParameterLists: Max: 7 MaxOptionalParameters: 5 -# Offense count: 44 -# Configuration parameters: IgnoredMethods. +# Offense count: 36 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 18 @@ -141,27 +170,84 @@ 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 +# 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 unsafe auto-correction (--auto-correct-all). -Style/CaseLikeIf: +# This cop supports safe autocorrection (--autocorrect). +Performance/RedundantBlockCall: + Exclude: + - 'lib/gherkin/parser.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Performance/RegexpMatch: Exclude: - 'lib/gherkin/gherkin_line.rb' - - 'lib/gherkin/token_matcher.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +RSpec/ContextMethod: + Exclude: + - 'spec/gherkin/gherkin_line_spec.rb' + - 'spec/gherkin/stream/parser_message_stream_spec.rb' + +# Offense count: 5 +# Configuration parameters: Prefixes, AllowedPatterns. +# 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 unsafe autocorrection (--autocorrect-all). +# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. +# 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: 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: @@ -169,13 +255,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. # 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: @@ -183,14 +270,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. 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: @@ -198,23 +285,23 @@ 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. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - 'lib/gherkin/ast_builder.rb' - 'lib/gherkin/gherkin_line.rb' -# Offense count: 54 -# This cop supports safe auto-correction (--auto-correct). +# Offense count: 46 +# 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: @@ -223,47 +310,63 @@ Style/PreferredHashMethods: - 'lib/gherkin/token_matcher.rb' # Offense count: 1 -# This cop supports safe auto-correction (--auto-correct). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedCompactTypes. # SupportedStyles: compact, exploded Style/RaiseArgs: Exclude: - 'lib/gherkin/parser.rb' -# Offense count: 50 -# This cop supports safe auto-correction (--auto-correct). +# Offense count: 46 +# 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: 66 -# This cop supports safe auto-correction (--auto-correct). +# Offense count: 58 +# 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: 1620 -# This cop supports safe auto-correction (--auto-correct). +# 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. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/gherkin/ast_builder.rb' + +# Offense count: 1342 +# 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: @@ -271,29 +374,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: 58 -# This cop supports safe auto-correction (--auto-correct). +# Offense count: 46 +# 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: @@ -302,8 +405,8 @@ Style/StringConcatenation: - 'lib/gherkin/gherkin_line.rb' - 'lib/gherkin/pickles/compiler.rb' -# Offense count: 411 -# This cop supports safe auto-correction (--auto-correct). +# Offense count: 343 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: @@ -316,7 +419,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: @@ -324,23 +427,29 @@ 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: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/SuperWithArgsParentheses: + Exclude: + - 'lib/gherkin/errors.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, 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: @@ -348,7 +457,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: @@ -356,7 +465,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: @@ -365,7 +474,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: @@ -373,7 +482,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/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/cucumber-gherkin.gemspec b/ruby/cucumber-gherkin.gemspec index bdad1b37b..258941937 100644 --- a/ruby/cucumber-gherkin.gemspec +++ b/ruby/cucumber-gherkin.gemspec @@ -27,7 +27,11 @@ 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.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.23.1' + s.add_development_dependency 'rubocop-rake', '~> 0.6.0' s.executables = %w[gherkin-ruby gherkin] s.files = Dir['README.md', 'LICENSE', 'lib/**/*'] diff --git a/ruby/gherkin-ruby.razor b/ruby/gherkin-ruby.razor index f648f623a..a5bfd1cee 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)) @@ -201,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) @@ -217,6 +218,5 @@ module Gherkin end default_value end - end end 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('@') diff --git a/ruby/lib/gherkin/parser.rb b/ruby/lib/gherkin/parser.rb index eb3ed9203..ce66d6132 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 @@ -3254,8 +3255,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) @@ -3270,6 +3271,5 @@ def handle_external_error(context, default_value, &action) end default_value end - end end 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 ccf3db715..6e15bedb3 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 @@ -29,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 @@ -38,14 +39,13 @@ 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}/) end end - context 'when set' do let(:id_generator) { double } let(:options) do @@ -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