Skip to content

Commit 491c14e

Browse files
authored
Rubocop bump (#1741)
* Pin rubocop gems and 0.x gems more aggressively * Update rubocop sub-gems * Remove redundant block / length based configs now rubocop-rspec and rubocop are updated * Partially fix up small param name cop * Regen of config / todo config * Update changelog * Fix issue with cs feature copied incorrectly * Fix pending spec * Fix bug with finnish translation of push that was missed during refactor
1 parent c10327a commit 491c14e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+296
-231
lines changed

.rubocop.yml

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ Metrics/AbcSize:
5252
- spec/cucumber/formatter/http_io_spec.rb
5353
- lib/cucumber/glue/proto_world.rb
5454

55-
# TODO: [LH] - This needs a re-review. I think we can pretty much delete / phase this out with incremental updates
56-
Metrics/BlockLength:
57-
CountComments: false
58-
Exclude:
59-
- './cucumber.gemspec'
60-
- './spec/**/*'
61-
- 'cck/spec/**/*'
62-
6355
# TODO: [LH] - This definitely needs a partial fix / reduction. Even if only an interim one that pushes some stuff
6456
Metrics/ClassLength:
6557
Max: 375
@@ -73,7 +65,6 @@ Metrics/ModuleLength:
7365
Max: 135
7466
Exclude:
7567
- './spec/**/*'
76-
- 'cck/spec/**/*'
7768
# TODO: Manually added! - be careful with regenning the file - this needs a fix
7869
- lib/cucumber/formatter/console.rb
7970

@@ -88,8 +79,7 @@ Metrics/MethodLength:
8879
- spec/cucumber/formatter/http_io_spec.rb
8980
- lib/cucumber/glue/proto_world.rb
9081

91-
# Rubocop doesn't like method names in other languages but as Cucumber supports
92-
# languages, this cop needs to be disabled.
82+
# Rubocop doesn't like method names in other languages but as Cucumber supports multiple languages, this cop needs to be disabled.
9383
Naming/AsciiIdentifiers:
9484
Enabled: false
9585

@@ -99,28 +89,8 @@ Naming/MethodName:
9989
Exclude:
10090
- 'examples/i18n/ar/lib/calculator.rb'
10191
- 'examples/i18n/he/lib/calculator.rb'
102-
- 'examples/i18n/he/lib/calculator.rb'
103-
- 'examples/i18n/tr/lib/hesap_makinesi.rb'
10492
- 'lib/cucumber/glue/dsl.rb'
10593

106-
# In most cases, being descriptive with parameter names helps a reader understand
107-
# what the variable is for. In some cases, shorter names are sufficient.
108-
Naming/MethodParameterName:
109-
AllowedNames: _, e, n, v, id, io, gh, pr
110-
111-
# Reviewed: these offenses look false as the variables are in cyrillic
112-
Naming/VariableName:
113-
Exclude:
114-
- 'examples/i18n/ru/features/step_definitions/calculator_steps.rb'
115-
- 'examples/i18n/uk/features/step_definitions/calculator_steps.rb'
116-
- 'examples/i18n/uz/features/step_definitions/calculator_steps.rb'
117-
118-
# Rubocop doesn't handle some international words well for this cop
119-
Naming/VariableNumber:
120-
EnforcedStyle: normalcase
121-
Exclude:
122-
- 'examples/i18n/**/*'
123-
12494
RSpec/ExampleLength:
12595
CountAsOne: ['array', 'hash', 'heredoc']
12696

.rubocop_todo.yml

Lines changed: 23 additions & 17 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-02 12:57:00 UTC using RuboCop version 1.56.3.
3+
# on 2023-10-02 14:25:13 UTC using RuboCop version 1.56.4.
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
@@ -88,21 +88,11 @@ Lint/RescueException:
8888
Exclude:
8989
- 'lib/cucumber/glue/proto_world.rb'
9090

91-
# Offense count: 1
92-
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
93-
Metrics/AbcSize:
94-
Max: 50
95-
9691
# Offense count: 8
9792
# Configuration parameters: AllowedMethods, AllowedPatterns.
9893
Metrics/CyclomaticComplexity:
9994
Max: 12
10095

101-
# Offense count: 1
102-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
103-
Metrics/MethodLength:
104-
Max: 57
105-
10696
# Offense count: 7
10797
# Configuration parameters: AllowedMethods, AllowedPatterns.
10898
Metrics/PerceivedComplexity:
@@ -116,6 +106,28 @@ Naming/FileName:
116106
Exclude:
117107
- 'features/lib/step_definitions/iso-8859-1_steps.rb'
118108

109+
# Offense count: 14
110+
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
111+
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
112+
Naming/MethodParameterName:
113+
Exclude:
114+
- 'lib/cucumber/cli/options.rb'
115+
- 'lib/cucumber/formatter/ansicolor.rb'
116+
- 'lib/cucumber/formatter/console.rb'
117+
- 'lib/cucumber/gherkin/formatter/ansi_escapes.rb'
118+
- 'lib/cucumber/multiline_argument/data_table.rb'
119+
120+
# Offense count: 8
121+
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
122+
# SupportedStyles: snake_case, normalcase, non_integer
123+
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
124+
Naming/VariableNumber:
125+
Exclude:
126+
- 'examples/i18n/bg/lib/calculator.rb'
127+
- 'examples/i18n/ru/lib/calculator.rb'
128+
- 'examples/i18n/uk/lib/calculator.rb'
129+
- 'examples/i18n/uz/lib/calculator.rb'
130+
119131
# Offense count: 2
120132
RSpec/AnyInstance:
121133
Exclude:
@@ -146,11 +158,6 @@ RSpec/ContextWording:
146158
# Configuration parameters: IgnoredMetadata.
147159
RSpec/DescribeClass:
148160
Exclude:
149-
- '**/spec/features/**/*'
150-
- '**/spec/requests/**/*'
151-
- '**/spec/routing/**/*'
152-
- '**/spec/system/**/*'
153-
- '**/spec/views/**/*'
154161
- 'spec/cck/cck_spec.rb'
155162

156163
# Offense count: 8
@@ -195,7 +202,6 @@ RSpec/ExampleWording:
195202
# This cop supports safe autocorrection (--autocorrect).
196203
RSpec/ExpectActual:
197204
Exclude:
198-
- '**/spec/routing/**/*'
199205
- 'spec/cucumber/cli/configuration_spec.rb'
200206
- 'spec/cucumber/step_match_spec.rb'
201207

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
1010

1111
## [Unreleased]
1212
### Changed
13-
- First couple of passes of tidying up approximately 30% of the manual fix cops
14-
([#1739](https://github.com/cucumber/cucumber-ruby/pull/1739) [#1740](https://github.com/cucumber/cucumber-ruby/pull/1740) [luke-hill](https://github.com/luke-hill))
13+
- First couple of passes of tidying up approximately 40% of the manual fix cops
14+
([#1739](https://github.com/cucumber/cucumber-ruby/pull/1739) [#1740](https://github.com/cucumber/cucumber-ruby/pull/1740) [#1741](https://github.com/cucumber/cucumber-ruby/pull/1741) [luke-hill](https://github.com/luke-hill))
1515
- Removed a bunch of example files / sample projects from ancient projects no longer viable
1616
[#1740](https://github.com/cucumber/cucumber-ruby/pull/1740) [luke-hill](https://github.com/luke-hill))
1717

cucumber.gemspec

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ Gem::Specification.new do |s|
3939
s.add_development_dependency 'pry', '~> 0.14', '>= 0.14.1'
4040
s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
4141
s.add_development_dependency 'rspec', '~> 3.12', '>= 3.12.0'
42-
s.add_development_dependency 'rubocop', '~> 1.56', '>= 1.56.2'
43-
s.add_development_dependency 'rubocop-capybara', '~> 2.18', '>= 2.18.0'
44-
s.add_development_dependency 'rubocop-packaging', '~> 0.5', '>= 0.5.2'
45-
s.add_development_dependency 'rubocop-rake', '~> 0.6', '>= 0.6.0'
46-
s.add_development_dependency 'rubocop-rspec', '~> 2.23', '>= 2.23.2'
47-
s.add_development_dependency 'simplecov', '~> 0.22', '>= 0.22.0'
42+
s.add_development_dependency 'rubocop', '~> 1.56.4'
43+
s.add_development_dependency 'rubocop-capybara', '~> 2.19.0'
44+
s.add_development_dependency 'rubocop-packaging', '~> 0.5.2'
45+
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
46+
s.add_development_dependency 'rubocop-rspec', '~> 2.24.1'
47+
s.add_development_dependency 'simplecov', '~> 0.22.0'
4848
s.add_development_dependency 'syntax', '~> 1.2', '>= 1.2.2'
4949
s.add_development_dependency 'test-unit', '~> 3.6', '>= 3.6.1'
5050
s.add_development_dependency 'webrick', '~> 1.8', '>= 1.8.1'

examples/i18n/ar/lib/calculator.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# frozen_string_literal: true
22

33
class Calculator
4-
def push(n)
5-
@args ||= []
6-
@args << n
4+
def initialize
5+
@stack = []
6+
end
7+
8+
def push(arg)
9+
@stack.push(arg)
710
end
811

912
def جمع
10-
@args.inject(0) { |n, sum| sum + n }
13+
@stack.inject(0) { |n, sum| sum + n }
1114
end
1215
end

examples/i18n/bg/lib/calculator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def initialize
66
end
77

88
def push(arg)
9-
@stack.push arg
9+
@stack.push(arg)
1010
end
1111

1212
def result

examples/i18n/ca/lib/calculadora.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# frozen_string_literal: true
22

33
class Calculadora
4-
def push(n)
5-
@args ||= []
6-
@args << n
4+
def initialize
5+
@stack = []
6+
end
7+
8+
def push(arg)
9+
@stack.push(arg)
710
end
811

912
def add
10-
@args.inject(0) { |n, sum| sum + n }
13+
@stack.inject(0) { |n, sum| sum + n }
1114
end
1215

1316
def divide
14-
@args[0].to_f / @args[1]
17+
@stack[0].to_f / @stack[1]
1518
end
1619
end

examples/i18n/cs/lib/calculator.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# frozen_string_literal: true
22

33
class Calculator
4-
def push(n)
5-
@args ||= []
6-
@args << n
4+
def initialize
5+
@stack = []
6+
end
7+
8+
def push(arg)
9+
@stack.push(arg)
710
end
811

912
def add
10-
@args.inject(0) { |n, sum| sum + n }
13+
@stack.inject(0) { |n, sum| sum + n }
1114
end
1215

1316
def divide
14-
@args[0].to_f / @args[1]
17+
@stack[0].to_f / @stack[1]
1518
end
1619
end

examples/i18n/da/lib/lommeregner.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# frozen_string_literal: true
22

33
class Lommeregner
4-
def push(n)
5-
@args ||= []
6-
@args << n
4+
def initialize
5+
@stack = []
6+
end
7+
8+
def push(arg)
9+
@stack.push(arg)
710
end
811

912
def add
10-
@args.inject(0) { |n, sum| sum + n }
13+
@stack.inject(0) { |n, sum| sum + n }
1114
end
1215
end

examples/i18n/de/lib/calculator.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# frozen_string_literal: true
22

33
class Calculator
4-
def push(n)
5-
@args ||= []
6-
@args << n
4+
def initialize
5+
@stack = []
6+
end
7+
8+
def push(arg)
9+
@stack.push(arg)
710
end
811

912
def add
10-
@args.inject(0) { |n, sum| sum + n }
13+
@stack.inject(0) { |n, sum| sum + n }
1114
end
1215

1316
def divide
14-
@args[0].to_f / @args[1]
17+
@stack[0].to_f / @stack[1]
1518
end
1619
end

0 commit comments

Comments
 (0)