Skip to content

Commit 2c3cad4

Browse files
authored
Ruby: Refactor/large autofixes (#233)
* AF (And then patch up), for Layout/ClosingParenthesisIndentation * AF: FrozenStringLiteral * AF: MutableConstant * AF: Style/Lambda * AF: Style/IfUnlessModifier * AF: Style/LineEndConcatenation * AF: StringLiterals * Re-gen config * Fix ident of 'to_hash * Create mutable string in generator * Stylistic manual fixes for returning an array without verbosely stating it is * use do/end for multiline block * Miscellaneous typos / minor remaining self-review issues * Update changelogs
1 parent aa4134a commit 2c3cad4

35 files changed

+641
-741
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99
### Changed
10-
- [Ruby] Minimum supported ruby is now 2.5+
11-
1210
- [JavaScript] Added TypeScript source to the package ([#211](https://github.com/cucumber/cucumber-expressions/pull/211))
11+
- [Ruby] Minimum supported ruby is now 2.5+ ([#232](https://github.com/cucumber/cucumber-expressions/pull/232))
12+
- [Ruby] Large suite wide refactor for basic rubocop compliance ([#233](https://github.com/cucumber/cucumber-expressions/pull/233))
1313

1414
## [16.1.2] - 2023-01-17
1515
### Fixed

ruby/.rubocop_todo.yml

Lines changed: 16 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-10-03 16:26:01 UTC using RuboCop version 1.27.0.
3+
# on 2023-10-03 17:06:00 UTC using RuboCop version 1.27.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -16,22 +16,7 @@ Layout/AccessModifierIndentation:
1616
Exclude:
1717
- 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb'
1818

19-
# Offense count: 45
20-
# This cop supports safe auto-correction (--auto-correct).
21-
Layout/ClosingParenthesisIndentation:
22-
Exclude:
23-
- 'lib/cucumber/cucumber_expressions/argument.rb'
24-
- 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb'
25-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
26-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb'
27-
- 'lib/cucumber/cucumber_expressions/errors.rb'
28-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
29-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
30-
- 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb'
31-
- 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
32-
- 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb'
33-
34-
# Offense count: 25
19+
# Offense count: 23
3520
# This cop supports safe auto-correction (--auto-correct).
3621
Layout/EmptyLineAfterGuardClause:
3722
Exclude:
@@ -40,12 +25,10 @@ Layout/EmptyLineAfterGuardClause:
4025
- 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb'
4126
- 'lib/cucumber/cucumber_expressions/cucumber_expression.rb'
4227
- 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
43-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb'
4428
- 'lib/cucumber/cucumber_expressions/parameter_type.rb'
4529
- 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb'
4630
- 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb'
4731
- 'lib/cucumber/cucumber_expressions/tree_regexp.rb'
48-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
4932
- 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
5033
- 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb'
5134

@@ -56,20 +39,18 @@ Layout/EmptyLineAfterMagicComment:
5639
- 'Gemfile'
5740
- 'Rakefile'
5841

59-
# Offense count: 2
42+
# Offense count: 1
6043
# This cop supports safe auto-correction (--auto-correct).
6144
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
6245
Layout/EmptyLineBetweenDefs:
6346
Exclude:
6447
- 'lib/cucumber/cucumber_expressions/ast.rb'
65-
- 'lib/cucumber/cucumber_expressions/errors.rb'
6648

67-
# Offense count: 3
49+
# Offense count: 2
6850
# This cop supports safe auto-correction (--auto-correct).
6951
Layout/EmptyLines:
7052
Exclude:
7153
- 'lib/cucumber/cucumber_expressions/ast.rb'
72-
- 'lib/cucumber/cucumber_expressions/errors.rb'
7354
- 'lib/cucumber/cucumber_expressions/parameter_type.rb'
7455

7556
# Offense count: 2
@@ -92,15 +73,13 @@ Layout/EmptyLinesAroundClassBody:
9273
- 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb'
9374
- 'lib/cucumber/cucumber_expressions/regular_expression.rb'
9475

95-
# Offense count: 4
76+
# Offense count: 1
9677
# This cop supports safe auto-correction (--auto-correct).
9778
# Configuration parameters: EnforcedStyle.
9879
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
9980
Layout/EmptyLinesAroundModuleBody:
10081
Exclude:
101-
- 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb'
10282
- 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb'
103-
- 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
10483

10584
# Offense count: 1
10685
# This cop supports safe auto-correction (--auto-correct).
@@ -109,23 +88,6 @@ Layout/ExtraSpacing:
10988
Exclude:
11089
- 'cucumber-cucumber-expressions.gemspec'
11190

112-
# Offense count: 47
113-
# This cop supports safe auto-correction (--auto-correct).
114-
# Configuration parameters: EnforcedStyle, IndentationWidth.
115-
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
116-
Layout/FirstArgumentIndentation:
117-
Exclude:
118-
- 'lib/cucumber/cucumber_expressions/argument.rb'
119-
- 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb'
120-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
121-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb'
122-
- 'lib/cucumber/cucumber_expressions/errors.rb'
123-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
124-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
125-
- 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb'
126-
- 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
127-
- 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb'
128-
12991
# Offense count: 4
13092
# This cop supports safe auto-correction (--auto-correct).
13193
# Configuration parameters: EnforcedStyle, IndentationWidth.
@@ -145,14 +107,6 @@ Layout/FirstHashElementIndentation:
145107
- 'cucumber-cucumber-expressions.gemspec'
146108
- 'lib/cucumber/cucumber_expressions/ast.rb'
147109

148-
# Offense count: 1
149-
# This cop supports safe auto-correction (--auto-correct).
150-
# Configuration parameters: EnforcedStyle, IndentationWidth.
151-
# SupportedStyles: consistent, align_parentheses
152-
Layout/FirstParameterIndentation:
153-
Exclude:
154-
- 'lib/cucumber/cucumber_expressions/errors.rb'
155-
156110
# Offense count: 4
157111
# This cop supports safe auto-correction (--auto-correct).
158112
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
@@ -176,15 +130,13 @@ Layout/HeredocIndentation:
176130
Layout/LineLength:
177131
Max: 252
178132

179-
# Offense count: 12
133+
# Offense count: 1
180134
# This cop supports safe auto-correction (--auto-correct).
181135
# Configuration parameters: EnforcedStyle.
182136
# SupportedStyles: symmetrical, new_line, same_line
183137
Layout/MultilineMethodCallBraceLayout:
184138
Exclude:
185-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
186139
- 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb'
187-
- 'spec/cucumber/cucumber_expressions/regular_expression_spec.rb'
188140

189141
# Offense count: 3
190142
# This cop supports safe auto-correction (--auto-correct).
@@ -194,15 +146,6 @@ Layout/MultilineMethodCallIndentation:
194146
Exclude:
195147
- 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb'
196148

197-
# Offense count: 2
198-
# This cop supports safe auto-correction (--auto-correct).
199-
# Configuration parameters: EnforcedStyle, IndentationWidth.
200-
# SupportedStyles: aligned, indented
201-
Layout/MultilineOperationIndentation:
202-
Exclude:
203-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb'
204-
- 'lib/cucumber/cucumber_expressions/errors.rb'
205-
206149
# Offense count: 2
207150
# This cop supports safe auto-correction (--auto-correct).
208151
# Configuration parameters: EnforcedStyle.
@@ -239,7 +182,7 @@ Layout/SpaceInLambdaLiteral:
239182
Exclude:
240183
- 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
241184

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

262-
# Offense count: 25
205+
# Offense count: 24
263206
# This cop supports safe auto-correction (--auto-correct).
264207
# Configuration parameters: EnforcedStyle.
265208
# SupportedStyles: space, compact, no_space
@@ -342,11 +285,11 @@ Lint/UnusedBlockArgument:
342285
Metrics/AbcSize:
343286
Max: 59
344287

345-
# Offense count: 12
288+
# Offense count: 11
346289
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
347290
# IgnoredMethods: refine
348291
Metrics/BlockLength:
349-
Max: 187
292+
Max: 183
350293

351294
# Offense count: 1
352295
# Configuration parameters: CountBlocks.
@@ -356,22 +299,22 @@ Metrics/BlockNesting:
356299
# Offense count: 1
357300
# Configuration parameters: CountComments, CountAsOne.
358301
Metrics/ClassLength:
359-
Max: 165
302+
Max: 151
360303

361304
# Offense count: 7
362305
# Configuration parameters: IgnoredMethods.
363306
Metrics/CyclomaticComplexity:
364307
Max: 15
365308

366-
# Offense count: 22
309+
# Offense count: 20
367310
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
368311
Metrics/MethodLength:
369-
Max: 77
312+
Max: 71
370313

371314
# Offense count: 4
372315
# Configuration parameters: CountComments, CountAsOne.
373316
Metrics/ModuleLength:
374-
Max: 188
317+
Max: 184
375318

376319
# Offense count: 1
377320
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
@@ -501,83 +444,26 @@ Style/FormatString:
501444
Exclude:
502445
- 'lib/cucumber/cucumber_expressions/generated_expression.rb'
503446

504-
# Offense count: 32
505-
# This cop supports safe auto-correction (--auto-correct).
506-
# Configuration parameters: EnforcedStyle.
507-
# SupportedStyles: always, always_true, never
508-
Style/FrozenStringLiteralComment:
509-
Enabled: false
510-
511-
# Offense count: 3
447+
# Offense count: 2
512448
# Configuration parameters: MinBodyLength.
513449
Style/GuardClause:
514450
Exclude:
515451
- 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb'
516-
- 'lib/cucumber/cucumber_expressions/parameter_type.rb'
517452
- 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb'
518453

519-
# Offense count: 27
520-
# This cop supports safe auto-correction (--auto-correct).
521-
Style/IfUnlessModifier:
522-
Exclude:
523-
- 'lib/cucumber/cucumber_expressions/ast.rb'
524-
- 'lib/cucumber/cucumber_expressions/combinatorial_generated_expression_factory.rb'
525-
- 'lib/cucumber/cucumber_expressions/cucumber_expression.rb'
526-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_generator.rb'
527-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
528-
- 'lib/cucumber/cucumber_expressions/cucumber_expression_tokenizer.rb'
529-
- 'lib/cucumber/cucumber_expressions/parameter_type.rb'
530-
- 'lib/cucumber/cucumber_expressions/parameter_type_matcher.rb'
531-
- 'lib/cucumber/cucumber_expressions/tree_regexp.rb'
532-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
533-
534454
# Offense count: 1
535455
# This cop supports unsafe auto-correction (--auto-correct-all).
536456
# Configuration parameters: InverseMethods, InverseBlocks.
537457
Style/InverseMethods:
538458
Exclude:
539459
- 'lib/cucumber/cucumber_expressions/parameter_type.rb'
540460

541-
# Offense count: 46
542-
# This cop supports safe auto-correction (--auto-correct).
543-
# Configuration parameters: EnforcedStyle.
544-
# SupportedStyles: line_count_dependent, lambda, literal
545-
Style/Lambda:
546-
Exclude:
547-
- 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb'
548-
- 'lib/cucumber/cucumber_expressions/regular_expression.rb'
549-
- 'spec/cucumber/cucumber_expressions/combinatorial_generated_expression_factory_test.rb'
550-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_generator_spec.rb'
551-
- 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
552-
- 'spec/cucumber/cucumber_expressions/custom_parameter_type_spec.rb'
553-
- 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
554-
- 'spec/cucumber/cucumber_expressions/parameter_type_spec.rb'
555-
556-
# Offense count: 21
557-
# This cop supports safe auto-correction (--auto-correct).
558-
Style/LineEndConcatenation:
559-
Exclude:
560-
- 'lib/cucumber/cucumber_expressions/errors.rb'
561-
- 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
562-
563461
# Offense count: 1
564462
# This cop supports safe auto-correction (--auto-correct).
565463
Style/MultilineTernaryOperator:
566464
Exclude:
567465
- 'spec/cucumber/cucumber_expressions/cucumber_expression_spec.rb'
568466

569-
# Offense count: 30
570-
# This cop supports safe auto-correction (--auto-correct).
571-
# Configuration parameters: EnforcedStyle.
572-
# SupportedStyles: literals, strict
573-
Style/MutableConstant:
574-
Exclude:
575-
- 'lib/cucumber/cucumber_expressions/ast.rb'
576-
- 'lib/cucumber/cucumber_expressions/cucumber_expression.rb'
577-
- 'lib/cucumber/cucumber_expressions/parameter_type.rb'
578-
- 'lib/cucumber/cucumber_expressions/parameter_type_registry.rb'
579-
- 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
580-
581467
# Offense count: 1
582468
# This cop supports safe auto-correction (--auto-correct).
583469
Style/NegatedIfElseCondition:
@@ -698,21 +584,13 @@ Style/Semicolon:
698584
Style/SpecialGlobalVars:
699585
EnforcedStyle: use_perl_names
700586

701-
# Offense count: 5
587+
# Offense count: 3
702588
# This cop supports unsafe auto-correction (--auto-correct-all).
703589
# Configuration parameters: Mode.
704590
Style/StringConcatenation:
705591
Exclude:
706592
- 'lib/cucumber/cucumber_expressions/cucumber_expression_parser.rb'
707593
- 'lib/cucumber/cucumber_expressions/errors.rb'
708-
- 'spec/cucumber/cucumber_expressions/parameter_type_registry_spec.rb'
709-
710-
# Offense count: 264
711-
# This cop supports safe auto-correction (--auto-correct).
712-
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
713-
# SupportedStyles: single_quotes, double_quotes
714-
Style/StringLiterals:
715-
Enabled: false
716594

717595
# Offense count: 7
718596
# This cop supports unsafe auto-correction (--auto-correct-all).

ruby/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# frozen_string_literal: true
2-
source "https://rubygems.org"
2+
source 'https://rubygems.org'
33
gemspec

ruby/Rakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# encoding: utf-8
2+
# frozen_string_literal: true
23
require 'rubygems'
34
require 'bundler'
45
Bundler::GemHelper.install_tasks
56

6-
$:.unshift File.expand_path("../lib", __FILE__)
7+
$:.unshift File.expand_path('../lib', __FILE__)
78

89
Dir['./rake/*.rb'].each do |f|
910
require f
1011
end
1112

12-
require "rspec/core/rake_task"
13+
require 'rspec/core/rake_task'
1314
RSpec::Core::RakeTask.new(:spec)
1415

1516
task default: :spec
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# -*- encoding: utf-8 -*-
2+
# frozen_string_literal: true
23

3-
version = File.read(File.expand_path("VERSION", __dir__)).strip
4+
version = File.read(File.expand_path('VERSION', __dir__)).strip
45

56
Gem::Specification.new do |s|
67
s.name = 'cucumber-cucumber-expressions'
78
s.version = version
8-
s.authors = ["Aslak Hellesøy"]
9+
s.authors = ['Aslak Hellesøy']
910
s.description = 'Cucumber Expressions - a simpler alternative to Regular Expressions'
1011
s.summary = "cucumber-expressions-#{s.version}"
1112
s.email = '[email protected]'
12-
s.homepage = "https://github.com/cucumber/cucumber-expressions-ruby#readme"
13+
s.homepage = 'https://github.com/cucumber/cucumber-expressions-ruby#readme'
1314
s.platform = Gem::Platform::RUBY
14-
s.license = "MIT"
15-
s.required_ruby_version = ">= 2.5"
15+
s.license = 'MIT'
16+
s.required_ruby_version = '>= 2.5'
1617

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

29-
s.rubygems_version = ">= 3.0.8"
30+
s.rubygems_version = '>= 3.0.8'
3031
s.files = `git ls-files`.split("\n").reject {|path| path =~ /\.gitignore$/ }
3132
s.test_files = `git ls-files -- spec/*`.split("\n")
32-
s.rdoc_options = ["--charset=UTF-8"]
33-
s.require_path = "lib"
33+
s.rdoc_options = ['--charset=UTF-8']
34+
s.require_path = 'lib'
3435
end

0 commit comments

Comments
 (0)