Skip to content

Ruby: Refactor/large autofixes #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ 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))
- [Ruby] Minimum supported ruby is now 2.5+ ([#232](https://github.com/cucumber/cucumber-expressions/pull/232))
- [Ruby] Large suite wide refactor for basic rubocop compliance ([#233](https://github.com/cucumber/cucumber-expressions/pull/233))

## [16.1.2] - 2023-01-17
### Fixed
Expand Down
154 changes: 16 additions & 138 deletions ruby/.rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-10-03 16:26:01 UTC using RuboCop version 1.27.0.
# on 2023-10-03 17:06:00 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
Expand All @@ -16,22 +16,7 @@ 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
# Offense count: 23
# This cop supports safe auto-correction (--auto-correct).
Layout/EmptyLineAfterGuardClause:
Exclude:
Expand All @@ -40,12 +25,10 @@ Layout/EmptyLineAfterGuardClause:
- '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'

Expand All @@ -56,20 +39,18 @@ Layout/EmptyLineAfterMagicComment:
- 'Gemfile'
- 'Rakefile'

# Offense count: 2
# Offense count: 1
# 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
# Offense count: 2
# 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
Expand All @@ -92,15 +73,13 @@ Layout/EmptyLinesAroundClassBody:
- 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb'
- 'lib/cucumber/cucumber_expressions/regular_expression.rb'

# Offense count: 4
# Offense count: 1
# 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).
Expand All @@ -109,23 +88,6 @@ 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.
Expand All @@ -145,14 +107,6 @@ Layout/FirstHashElementIndentation:
- '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.
Expand All @@ -176,15 +130,13 @@ Layout/HeredocIndentation:
Layout/LineLength:
Max: 252

# Offense count: 12
# Offense count: 1
# 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).
Expand All @@ -194,15 +146,6 @@ 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.
Expand Down Expand Up @@ -239,7 +182,7 @@ Layout/SpaceInLambdaLiteral:
Exclude:
- 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'

# Offense count: 101
# Offense count: 58
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
Expand All @@ -259,7 +202,7 @@ Layout/SpaceInsideBlockBraces:
- 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb'
- 'spec/cucumber/cucumber_expressions/tree_regexp_spec.rb'

# Offense count: 25
# Offense count: 24
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, compact, no_space
Expand Down Expand Up @@ -342,11 +285,11 @@ Lint/UnusedBlockArgument:
Metrics/AbcSize:
Max: 59

# Offense count: 12
# Offense count: 11
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 187
Max: 183

# Offense count: 1
# Configuration parameters: CountBlocks.
Expand All @@ -356,22 +299,22 @@ Metrics/BlockNesting:
# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 165
Max: 151

# Offense count: 7
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 15

# Offense count: 22
# Offense count: 20
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 77
Max: 71

# Offense count: 4
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 188
Max: 184

# Offense count: 1
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Expand Down Expand Up @@ -501,83 +444,26 @@ 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
# Offense count: 2
# 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:
Expand Down Expand Up @@ -698,21 +584,13 @@ Style/Semicolon:
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names

# Offense count: 5
# Offense count: 3
# 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).
Expand Down
2 changes: 1 addition & 1 deletion ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true
source "https://rubygems.org"
source 'https://rubygems.org'
gemspec
5 changes: 3 additions & 2 deletions ruby/Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# encoding: utf-8
# frozen_string_literal: true
require 'rubygems'
require 'bundler'
Bundler::GemHelper.install_tasks

$:.unshift File.expand_path("../lib", __FILE__)
$:.unshift File.expand_path('../lib', __FILE__)

Dir['./rake/*.rb'].each do |f|
require f
end

require "rspec/core/rake_task"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task default: :spec
17 changes: 9 additions & 8 deletions ruby/cucumber-cucumber-expressions.gemspec
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# -*- encoding: utf-8 -*-
# frozen_string_literal: true

version = File.read(File.expand_path("VERSION", __dir__)).strip
version = File.read(File.expand_path('VERSION', __dir__)).strip

Gem::Specification.new do |s|
s.name = 'cucumber-cucumber-expressions'
s.version = version
s.authors = ["Aslak Hellesøy"]
s.authors = ['Aslak Hellesøy']
s.description = 'Cucumber Expressions - a simpler alternative to Regular Expressions'
s.summary = "cucumber-expressions-#{s.version}"
s.email = '[email protected]'
s.homepage = "https://github.com/cucumber/cucumber-expressions-ruby#readme"
s.homepage = 'https://github.com/cucumber/cucumber-expressions-ruby#readme'
s.platform = Gem::Platform::RUBY
s.license = "MIT"
s.required_ruby_version = ">= 2.5"
s.license = 'MIT'
s.required_ruby_version = '>= 2.5'

s.metadata = {
'bug_tracker_uri' => 'https://github.com/cucumber/cucumber/issues',
Expand All @@ -26,9 +27,9 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rspec', '~> 3.11', '>= 3.11.0'
s.add_development_dependency 'rubocop', '~> 1.27.0'

s.rubygems_version = ">= 3.0.8"
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"]
s.require_path = "lib"
s.rdoc_options = ['--charset=UTF-8']
s.require_path = 'lib'
end
Loading