diff --git a/.github/workflows/release-rubygem.yml b/.github/workflows/release-rubygem.yml index b12f9bffd..0314b2b2d 100644 --- a/.github/workflows/release-rubygem.yml +++ b/.github/workflows/release-rubygem.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0.2' + ruby-version: '3.2' bundler-cache: true - uses: cucumber/action-publish-rubygem@v1.0.0 with: diff --git a/.github/workflows/test-ruby.yml b/.github/workflows/test-ruby.yml index 864351c34..f89f37369 100644 --- a/.github/workflows/test-ruby.yml +++ b/.github/workflows/test-ruby.yml @@ -17,21 +17,20 @@ jobs: matrix: os: - ubuntu-latest - ruby: ['2.7', '3.0'] + ruby: ['2.7', '3.0', '3.1', '3.2'] include: - os: windows-latest - ruby: '3.0' + ruby: '3.2' - os: macos-latest - ruby: '3.0' + ruby: '3.2' steps: - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 + - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true working-directory: ruby - - name: bundle exec rspec + - name: rspec working-directory: ruby run: bundle exec rspec diff --git a/CHANGELOG.md b/CHANGELOG.md index e49dc8456..b71c5488c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed +- [Ruby] Minimum supported ruby is now 2.5+ - [JavaScript] Added TypeScript source to the package ([#211](https://github.com/cucumber/cucumber-expressions/pull/211)) diff --git a/ruby/.gitignore b/ruby/.gitignore index 2d16bb2af..d2c474cc6 100644 --- a/ruby/.gitignore +++ b/ruby/.gitignore @@ -3,8 +3,5 @@ coverage/ acceptance/ pkg/ *.gem -.compared .deps -.tested* -*-go *.iml diff --git a/ruby/.rspec b/ruby/.rspec deleted file mode 100644 index 4e1e0d2f7..000000000 --- a/ruby/.rspec +++ /dev/null @@ -1 +0,0 @@ ---color diff --git a/ruby/.rubocop.yml b/ruby/.rubocop.yml new file mode 100644 index 000000000..835d9835d --- /dev/null +++ b/ruby/.rubocop.yml @@ -0,0 +1,27 @@ +inherit_from: .rubocop_todo.yml + +inherit_mode: + merge: + - Exclude + +AllCops: + TargetRubyVersion: 2.5 + NewCops: enable + +# Disabled on our repo's to enable polyglot-release +Gemspec/RequireMFA: + Enabled: false + +Layout/LineLength: + Max: 200 + +Style/Documentation: + Enabled: false + +Style/RegexpLiteral: + EnforcedStyle: slashes + AllowInnerSlashes: true + +# Once we enable rubocop-rspec +#RSpec/MessageSpies: +# EnforcedStyle: receive diff --git a/ruby/.rubocop_todo.yml b/ruby/.rubocop_todo.yml new file mode 100644 index 000000000..c41ac704f --- /dev/null +++ b/ruby/.rubocop_todo.yml @@ -0,0 +1,774 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-10-03 16:26:01 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: Oct '23 -> 33 files inspected, 1004 offenses detected, 859 offenses auto-correctable + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: outdent, indent +Layout/AccessModifierIndentation: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb' + +# Offense count: 45 +# This cop supports safe auto-correction (--auto-correct). +Layout/ClosingParenthesisIndentation: + Exclude: + - 'lib/cucumber/cucumber_expressions/argument.rb' + - 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + - 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb' + +# Offense count: 25 +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/cucumber/cucumber_expressions/argument.rb' + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + - 'lib/cucumber/cucumber_expressions/tree_regexp.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + - 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'Gemfile' + - 'Rakefile' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + +# Offense count: 3 +# This cop supports safe auto-correction (--auto-correct). +Layout/EmptyLines: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb' + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + - 'lib/cucumber/cucumber_expressions/regular_expression.rb' + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb' + - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'cucumber-cucumber-expressions.gemspec' + +# Offense count: 47 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Layout/FirstArgumentIndentation: + Exclude: + - 'lib/cucumber/cucumber_expressions/argument.rb' + - 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + - 'spec/cucumber/cucumber_expressions/regular_expression_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: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb' + +# Offense count: 3 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + Exclude: + - 'cucumber-cucumber-expressions.gemspec' + - 'lib/cucumber/cucumber_expressions/ast.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, align_parentheses +Layout/FirstParameterIndentation: + Exclude: + - 'lib/cucumber/cucumber_expressions/errors.rb' + +# Offense count: 4 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'cucumber-cucumber-expressions.gemspec' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +Layout/HeredocIndentation: + Exclude: + - 'lib/cucumber/cucumber_expressions/errors.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 252 + +# Offense count: 12 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Exclude: + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb' + - 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb' + +# Offense count: 3 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'lib/cucumber/cucumber_expressions/argument.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + +# Offense count: 5 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# SupportedStylesForExponentOperator: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'cucumber-cucumber-expressions.gemspec' + - 'lib/cucumber/cucumber_expressions/tree_regexp.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Exclude: + - 'spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb' + - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_no_space, require_space +Layout/SpaceInLambdaLiteral: + Exclude: + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + +# Offense count: 101 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'cucumber-cucumber-expressions.gemspec' + - 'lib/cucumber/cucumber_expressions/group_builder.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + - 'lib/cucumber/cucumber_expressions/regular_expression.rb' + - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb' + - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb' + - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb' + +# Offense count: 25 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, compact, no_space +Layout/SpaceInsideParens: + Exclude: + - 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Exclude: + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Lint/AmbiguousOperatorPrecedence: + Exclude: + - 'lib/cucumber/cucumber_expressions/errors.rb' + +# Offense count: 3 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + +# Offense count: 8 +# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. +Lint/DuplicateBranch: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + +# Offense count: 10 +# Configuration parameters: AllowComments. +Lint/EmptyClass: + Exclude: + - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + +# Offense count: 1 +Lint/MixedRegexpCaptureTypes: + Exclude: + - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb' + +# Offense count: 1 +# This cop supports unsafe auto-correction (--auto-correct-all). +Lint/NonDeterministicRequireOrder: + Exclude: + - 'Rakefile' + +# Offense count: 1 +Lint/NonLocalExitFromIterator: + Exclude: + - 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb' + +# Offense count: 7 +# Configuration parameters: AllowKeywordBlockArguments. +Lint/UnderscorePrefixedVariableName: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/group.rb' + +# Offense count: 14 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + +# Offense count: 10 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 59 + +# Offense count: 12 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine +Metrics/BlockLength: + Max: 187 + +# Offense count: 1 +# Configuration parameters: CountBlocks. +Metrics/BlockNesting: + Max: 4 + +# Offense count: 1 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 165 + +# Offense count: 7 +# Configuration parameters: IgnoredMethods. +Metrics/CyclomaticComplexity: + Max: 15 + +# Offense count: 22 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +Metrics/MethodLength: + Max: 77 + +# Offense count: 4 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ModuleLength: + Max: 188 + +# Offense count: 1 +# Configuration parameters: CountKeywordArgs, MaxOptionalParameters. +Metrics/ParameterLists: + Max: 6 + +# Offense count: 6 +# Configuration parameters: IgnoredMethods. +Metrics/PerceivedComplexity: + Max: 17 + +# Offense count: 10 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +Naming/BlockParameterName: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + +# Offense count: 2 +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +Naming/HeredocDelimiterNaming: + Exclude: + - 'lib/cucumber/cucumber_expressions/errors.rb' + +# Offense count: 7 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb' + - 'lib/cucumber/cucumber_expressions/tree_regexp.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb' + +# Offense count: 3 +# 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: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + - 'lib/cucumber/cucumber_expressions/tree_regexp.rb' + +# Offense count: 20 +# Configuration parameters: EnforcedStyle, AllowedIdentifiers. +# SupportedStyles: snake_case, camelCase +Naming/VariableName: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + +# Offense count: 2 +# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols. +# SupportedStyles: inline, group +Style/AccessModifierDeclarations: + Exclude: + - 'lib/cucumber/cucumber_expressions/tree_regexp.rb' + +# Offense count: 7 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb' + - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb' + - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb' + +# Offense count: 1 +# This cop supports unsafe auto-correction (--auto-correct-all). +Style/CaseLikeIf: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + +# Offense count: 3 +# This cop supports safe auto-correction (--auto-correct). +Style/ColonMethodCall: + Exclude: + - 'lib/cucumber/cucumber_expressions/errors.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/EmptyLiteral: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +Style/Encoding: + Exclude: + - 'Rakefile' + - 'cucumber-cucumber-expressions.gemspec' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/ExpandPathArguments: + Exclude: + - 'Rakefile' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: each, for +Style/For: + Exclude: + - 'lib/cucumber/cucumber_expressions/errors.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Exclude: + - 'lib/cucumber/cucumber_expressions/generated_expression.rb' + +# Offense count: 32 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 3 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + +# Offense count: 27 +# This cop supports safe auto-correction (--auto-correct). +Style/IfUnlessModifier: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + - 'lib/cucumber/cucumber_expressions/tree_regexp.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + +# Offense count: 1 +# This cop supports unsafe auto-correction (--auto-correct-all). +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + +# Offense count: 46 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: line_count_dependent, lambda, literal +Style/Lambda: + Exclude: + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + - 'lib/cucumber/cucumber_expressions/regular_expression.rb' + - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb' + +# Offense count: 21 +# This cop supports safe auto-correction (--auto-correct). +Style/LineEndConcatenation: + Exclude: + - 'lib/cucumber/cucumber_expressions/errors.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/MultilineTernaryOperator: + Exclude: + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + +# Offense count: 30 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/NegatedIfElseCondition: + Exclude: + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/NestedTernaryOperator: + Exclude: + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: IncludeSemanticChanges. +Style/NonNilCheck: + Exclude: + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + +# Offense count: 11 +# This cop supports unsafe auto-correction (--auto-correct-all). +# Configuration parameters: EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + +# Offense count: 6 +# This cop supports safe auto-correction (--auto-correct). +Style/ParallelAssignment: + Exclude: + - 'lib/cucumber/cucumber_expressions/argument.rb' + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/generated_expression.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb' + - 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/PerlBackrefs: + Exclude: + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + +# Offense count: 1 +# This cop supports unsafe auto-correction (--auto-correct-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + +# Offense count: 9 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowedCompactTypes. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + EnforcedStyle: compact + +# Offense count: 6 +# This cop supports unsafe auto-correction (--auto-correct-all). +# Configuration parameters: Methods. +Style/RedundantArgument: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantInterpolation: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantRegexpCharacterClass: + Exclude: + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + +# Offense count: 19 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/RedundantSelf: + Exclude: + - 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/SelectByRegexp: + Exclude: + - 'cucumber-cucumber-expressions.gemspec' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: AllowAsExpressionSeparator. +Style/Semicolon: + Exclude: + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: RequireEnglish. +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + EnforcedStyle: use_perl_names + +# Offense count: 5 +# This cop supports unsafe auto-correction (--auto-correct-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + - 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb' + +# Offense count: 264 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Enabled: false + +# Offense count: 7 +# This cop supports unsafe auto-correction (--auto-correct-all). +# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods. +# IgnoredMethods: respond_to, define_method +Style/SymbolProc: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'lib/cucumber/cucumber_expressions/errors.rb' + - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb' + - 'spec/cucumber/cucumber_expressions/cucumber_expression_tokenizer_spec.rb' + - 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb' + +# Offense count: 2 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + - 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'cucumber-cucumber-expressions.gemspec' + +# Offense count: 9 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. +# AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: + Exclude: + - 'lib/cucumber/cucumber_expressions/ast.rb' + +# Offense count: 1 +# This cop supports safe auto-correction (--auto-correct). +Style/WhileUntilDo: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb' + +# Offense count: 6 +# This cop supports safe auto-correction (--auto-correct). +# Configuration parameters: MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: brackets + +# Offense count: 6 +# This cop supports unsafe auto-correction (--auto-correct-all). +Style/ZeroLengthPredicate: + Exclude: + - 'lib/cucumber/cucumber_expressions/cucumber_expression.rb' + - 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb' + - 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb' diff --git a/ruby/Rakefile b/ruby/Rakefile index 85e0fc70a..4c21117ba 100644 --- a/ruby/Rakefile +++ b/ruby/Rakefile @@ -12,14 +12,4 @@ end require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) -require_relative 'spec/capture_warnings' -include CaptureWarnings -namespace :spec do - task :warnings do - report_warnings do - Rake::Task['spec'].invoke - end - end -end - -task default: ['spec:warnings'] +task default: :spec diff --git a/ruby/cucumber-cucumber-expressions.gemspec b/ruby/cucumber-cucumber-expressions.gemspec index 98554996c..ea67419d2 100644 --- a/ruby/cucumber-cucumber-expressions.gemspec +++ b/ruby/cucumber-cucumber-expressions.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/cucumber/cucumber-expressions-ruby#readme" s.platform = Gem::Platform::RUBY s.license = "MIT" - s.required_ruby_version = ">= 2.3" + s.required_ruby_version = ">= 2.5" s.metadata = { 'bug_tracker_uri' => 'https://github.com/cucumber/cucumber/issues', @@ -24,8 +24,9 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' s.add_development_dependency 'rspec', '~> 3.11', '>= 3.11.0' + s.add_development_dependency 'rubocop', '~> 1.27.0' - s.rubygems_version = ">= 1.6.1" + s.rubygems_version = ">= 3.0.8" s.files = `git ls-files`.split("\n").reject {|path| path =~ /\.gitignore$/ } s.test_files = `git ls-files -- spec/*`.split("\n") s.rdoc_options = ["--charset=UTF-8"] diff --git a/ruby/scripts/update-gemspec b/ruby/scripts/update-gemspec deleted file mode 100755 index d45401fd5..000000000 --- a/ruby/scripts/update-gemspec +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -# -# Updates the *.gemspec in the current directory to use the latest releases of gems -# -set -uf -o pipefail -IFS=$'\n' - -gemspec=$(find . -maxdepth 1 -type f -name "*.gemspec") -if [ "${gemspec}" = "" ]; then - exit 0 -fi -add_dependency_lines=$(cat ${gemspec} | grep "s.add_[a-z_]*dependency '[^']*'") -if [ $? -ne 0 ]; then - # No add_dependency_lines found - nothing to do - exit 0 -fi - -set -e - -gems=$(echo "${add_dependency_lines}" | tr -s ' ' | cut -d ' ' -f3 | cut -d"'" -f 2) -while read -r gem; do - echo "upgrading ${gem}" - if [ "${gem}" = "bundler" ]; then - cat "${gemspec}" | sed "s/\(s.add_[a-z_]*dependency\) '${gem}'.*/\1 '${gem}', '>= 1.16.2'/" > ${gemspec}.tmp - else - gem_line=$(gem list "${gem}" --remote --all --no-prerelease | grep "^${gem}\s") - latest_patch_version=$(echo "${gem_line}" | cut -d'(' -f2 | cut -d')' -f1 | cut -d',' -f1 | cut -d' ' -f1) - latest_minor_version=$(echo "${latest_patch_version}" | cut -d. -f1,2) - cat "${gemspec}" | sed "s/\(s.add_[a-z_]*dependency\) '${gem}'.*/\1 '${gem}', '~> ${latest_minor_version}', '>= ${latest_patch_version}'/" > ${gemspec}.tmp - fi - mv ${gemspec}.tmp ${gemspec} -done <<< "${gems}" diff --git a/ruby/spec/capture_warnings.rb b/ruby/spec/capture_warnings.rb deleted file mode 100644 index 2315009db..000000000 --- a/ruby/spec/capture_warnings.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true -# With thanks to @myronmarston -# https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb - -module CaptureWarnings - def report_warnings(&block) - current_dir = Dir.pwd - warnings, errors = capture_error(&block).partition { |line| line.include?('warning') } - project_warnings, other_warnings = warnings.uniq.partition { |line| line.include?(current_dir) } - - if errors.any? - puts errors.join("\n") - end - - if other_warnings.any? - puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them." - print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS'] - end - - # Until they fix https://bugs.ruby-lang.org/issues/10661 - if RUBY_VERSION == "2.2.0" - project_warnings = project_warnings.reject { |w| w =~ /warning: possible reference to past scope/ } - end - - if project_warnings.any? - puts "#{ project_warnings.count } warnings detected" - print_warnings('cucumber-expressions', project_warnings) - fail "Please remove all cucumber-expressions warnings." - end - - ensure_system_exit_if_required - end - - def capture_error(&block) - old_stderr = STDERR.clone - pipe_r, pipe_w = IO.pipe - pipe_r.sync = true - error = String.new - reader = Thread.new do - begin - loop do - error << pipe_r.readpartial(1024) - end - rescue EOFError - end - end - STDERR.reopen(pipe_w) - block.call - ensure - capture_system_exit - STDERR.reopen(old_stderr) - pipe_w.close - reader.join - return error.split("\n") - end - - def print_warnings(type, warnings) - puts - puts "-" * 30 + " #{type} warnings: " + "-" * 30 - puts - puts warnings.join("\n") - puts - puts "-" * 75 - puts - end - - def ensure_system_exit_if_required - raise @system_exit if @system_exit - end - - def capture_system_exit - @system_exit = $! - end -end