Skip to content

Commit b142d86

Browse files
authored
Refactor/rubocop af part2 (#1737)
* AF (And manual): RSpec/BeEql * AF: RSpec/DescribedClass * AF: RSpec/PredicateMatcher * Partial fix for AF: Style/ModuleAndClassChildren * AF: Style/FloatDivision * Manual fix and AF refactor of Style/SafeNavigation * AF: FrozenMutableConstant * Partial commit temporary pending rebase * Regen of todo file post merge conflict fixes * Manual fixes to poor merge for interceptor_spec * Add changelog * Autofix more DescribedClass issues post merge
1 parent fbe6108 commit b142d86

File tree

79 files changed

+533
-521
lines changed

Some content is hidden

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

79 files changed

+533
-521
lines changed

.rubocop_todo.yml

Lines changed: 60 additions & 59 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-09-06 13:00:58 UTC using RuboCop version 1.56.2.
3+
# on 2023-09-07 08:42:40 UTC using RuboCop version 1.56.2.
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
@@ -41,6 +41,12 @@ Lint/SuppressedException:
4141
Exclude:
4242
- 'lib/cucumber/rake/task.rb'
4343

44+
# Offense count: 1
45+
# This cop supports unsafe autocorrection (--autocorrect-all).
46+
Lint/UselessAssignment:
47+
Exclude:
48+
- 'spec/cucumber/formatter/interceptor_spec.rb'
49+
4450
# Offense count: 9
4551
# Configuration parameters: AllowedMethods, AllowedPatterns.
4652
Metrics/CyclomaticComplexity:
@@ -64,14 +70,6 @@ RSpec/AnyInstance:
6470
Exclude:
6571
- 'spec/cucumber/cli/main_spec.rb'
6672

67-
# Offense count: 5
68-
# This cop supports unsafe autocorrection (--autocorrect-all).
69-
RSpec/BeEql:
70-
Exclude:
71-
- 'spec/cucumber/cli/configuration_spec.rb'
72-
- 'spec/cucumber/cli/options_spec.rb'
73-
- 'spec/cucumber/glue/registry_and_more_spec.rb'
74-
7573
# Offense count: 9
7674
# This cop supports safe autocorrection (--autocorrect).
7775
# Configuration parameters: EnabledMethods.
@@ -96,12 +94,15 @@ RSpec/DescribeClass:
9694
- '**/spec/views/**/*'
9795
- 'spec/cck/cck_spec.rb'
9896

99-
# Offense count: 167
97+
# Offense count: 18
10098
# This cop supports unsafe autocorrection (--autocorrect-all).
10199
# Configuration parameters: SkipBlocks, EnforcedStyle.
102100
# SupportedStyles: described_class, explicit
103101
RSpec/DescribedClass:
104-
Enabled: false
102+
Exclude:
103+
- 'spec/cucumber/formatter/interceptor_spec.rb'
104+
- 'spec/cucumber/multiline_argument/data_table_spec.rb'
105+
- 'spec/cucumber/runtime/support_code_spec.rb'
105106

106107
# Offense count: 2
107108
# This cop supports unsafe autocorrection (--autocorrect-all).
@@ -110,11 +111,27 @@ RSpec/EmptyExampleGroup:
110111
- 'spec/cucumber/filters/activate_steps_spec.rb'
111112
- 'spec/cucumber/running_test_case_spec.rb'
112113

114+
# Offense count: 4
115+
# This cop supports safe autocorrection (--autocorrect).
116+
RSpec/EmptyLineAfterFinalLet:
117+
Exclude:
118+
- 'spec/cucumber/cli/main_spec.rb'
119+
- 'spec/cucumber/configuration_spec.rb'
120+
- 'spec/cucumber/hooks_spec.rb'
121+
113122
# Offense count: 150
114123
# Configuration parameters: CountAsOne.
115124
RSpec/ExampleLength:
116125
Max: 58
117126

127+
# Offense count: 4
128+
# This cop supports safe autocorrection (--autocorrect).
129+
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
130+
# DisallowedExamples: works
131+
RSpec/ExampleWording:
132+
Exclude:
133+
- 'spec/cucumber/multiline_argument/data_table_spec.rb'
134+
118135
# Offense count: 2
119136
# This cop supports safe autocorrection (--autocorrect).
120137
RSpec/ExpectActual:
@@ -129,18 +146,24 @@ RSpec/ExpectInHook:
129146
- 'spec/cucumber/multiline_argument/data_table_spec.rb'
130147
- 'spec/cucumber/runtime/meta_message_builder_spec.rb'
131148

132-
# Offense count: 6
149+
# Offense count: 9
133150
RSpec/ExpectOutput:
134151
Exclude:
135152
- 'spec/cucumber/formatter/interceptor_spec.rb'
136153

137-
# Offense count: 68
154+
# Offense count: 71
138155
# This cop supports safe autocorrection (--autocorrect).
139156
# Configuration parameters: EnforcedStyle.
140157
# SupportedStyles: implicit, each, example
141158
RSpec/HookArgument:
142159
Enabled: false
143160

161+
# Offense count: 4
162+
# This cop supports safe autocorrection (--autocorrect).
163+
RSpec/HooksBeforeExamples:
164+
Exclude:
165+
- 'spec/cucumber/formatter/interceptor_spec.rb'
166+
144167
# Offense count: 15
145168
# Configuration parameters: AssignmentOnly.
146169
RSpec/InstanceVariable:
@@ -188,6 +211,12 @@ RSpec/MultipleExpectations:
188211
RSpec/MultipleMemoizedHelpers:
189212
Max: 15
190213

214+
# Offense count: 1
215+
# This cop supports safe autocorrection (--autocorrect).
216+
RSpec/MultipleSubjects:
217+
Exclude:
218+
- 'spec/cucumber/runtime/support_code_spec.rb'
219+
191220
# Offense count: 46
192221
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
193222
# SupportedStyles: always, named_only
@@ -207,14 +236,10 @@ RSpec/NamedSubject:
207236
RSpec/NestedGroups:
208237
Max: 6
209238

210-
# Offense count: 4
211-
# This cop supports unsafe autocorrection (--autocorrect-all).
212-
# Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers.
213-
# SupportedStyles: inflected, explicit
214-
RSpec/PredicateMatcher:
239+
# Offense count: 1
240+
RSpec/OverwritingSetup:
215241
Exclude:
216-
- 'spec/cucumber/hooks_spec.rb'
217-
- 'spec/cucumber/running_test_case_spec.rb'
242+
- 'spec/cucumber/runtime/support_code_spec.rb'
218243

219244
# Offense count: 2
220245
# This cop supports safe autocorrection (--autocorrect).
@@ -229,9 +254,10 @@ RSpec/RepeatedExample:
229254
- 'spec/cucumber/formatter/rerun_spec.rb'
230255
- 'spec/cucumber/world/pending_spec.rb'
231256

232-
# Offense count: 2
257+
# Offense count: 4
233258
RSpec/RepeatedExampleGroupDescription:
234259
Exclude:
260+
- 'spec/cucumber/formatter/interceptor_spec.rb'
235261
- 'spec/cucumber/glue/proto_world_spec.rb'
236262

237263
# Offense count: 31
@@ -251,6 +277,18 @@ RSpec/ReturnFromStub:
251277
- 'spec/cucumber/formatter/junit_spec.rb'
252278
- 'spec/cucumber/glue/registry_and_more_spec.rb'
253279

280+
# Offense count: 3
281+
# This cop supports safe autocorrection (--autocorrect).
282+
RSpec/ScatteredLet:
283+
Exclude:
284+
- 'spec/cucumber/runtime/support_code_spec.rb'
285+
286+
# Offense count: 2
287+
# This cop supports safe autocorrection (--autocorrect).
288+
RSpec/ScatteredSetup:
289+
Exclude:
290+
- 'spec/cucumber/formatter/interceptor_spec.rb'
291+
254292
# Offense count: 9
255293
RSpec/StubbedMock:
256294
Exclude:
@@ -278,14 +316,7 @@ RSpec/VerifiedDoubles:
278316
- 'spec/cucumber/runtime/support_code_spec.rb'
279317
- 'spec/cucumber/world/pending_spec.rb'
280318

281-
# Offense count: 2
282-
# This cop supports safe autocorrection (--autocorrect).
283-
Rake/Desc:
284-
Exclude:
285-
- 'gem_tasks/contributors.rake'
286-
- 'gem_tasks/environment.rake'
287-
288-
# Offense count: 11
319+
# Offense count: 7
289320
# This cop supports unsafe autocorrection (--autocorrect-all).
290321
# Configuration parameters: EnforcedStyle.
291322
# SupportedStyles: nested, compact
@@ -298,38 +329,8 @@ Style/ClassAndModuleChildren:
298329
- 'lib/autotest/cucumber_rails_rspec2.rb'
299330
- 'lib/autotest/cucumber_rspec.rb'
300331
- 'lib/autotest/cucumber_rspec2.rb'
301-
- 'spec/cucumber/deprecate_spec.rb'
302-
- 'spec/cucumber/formatter/fail_fast_spec.rb'
303-
- 'spec/cucumber/formatter/interceptor_spec.rb'
304-
- 'spec/cucumber/hooks_spec.rb'
305332

306333
# Offense count: 3
307334
Style/ClassVars:
308335
Exclude:
309336
- 'spec/cucumber/glue/step_definition_spec.rb'
310-
311-
# Offense count: 22
312-
# This cop supports unsafe autocorrection (--autocorrect-all).
313-
# Configuration parameters: EnforcedStyle.
314-
# SupportedStyles: left_coerce, right_coerce, single_coerce, fdiv
315-
Style/FloatDivision:
316-
Enabled: false
317-
318-
# Offense count: 5
319-
# This cop supports unsafe autocorrection (--autocorrect-all).
320-
# Configuration parameters: EnforcedStyle.
321-
# SupportedStyles: literals, strict
322-
Style/MutableConstant:
323-
Exclude:
324-
- 'lib/cucumber/cli/options.rb'
325-
- 'lib/cucumber/file_specs.rb'
326-
- 'lib/cucumber/runtime.rb'
327-
- 'lib/cucumber/term/ansicolor.rb'
328-
329-
# Offense count: 1
330-
# This cop supports unsafe autocorrection (--autocorrect-all).
331-
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
332-
# AllowedMethods: present?, blank?, presence, try, try!
333-
Style/SafeNavigation:
334-
Exclude:
335-
- 'lib/cucumber/gherkin/formatter/ansi_escapes.rb'

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
1919

2020
- Rubocop update. Massively overhauled the cucumber style / rubocop expectations and began to tackle some long-standing tech-debt ([#1733](https://github.com/cucumber/cucumber-ruby/pull/1733) [luke-hill](https://github.com/luke-hill))
2121

22+
- First couple of passes of tidying up approximately 15% of the autofix cops
23+
([#1736](https://github.com/cucumber/cucumber-ruby/pull/1736) [#1737](https://github.com/cucumber/cucumber-ruby/pull/1737) [luke-hill](https://github.com/luke-hill))
24+
2225
## [9.0.1] - 2023-09-01
2326
### Changed
2427
- Update dependency of a few associated cucumber sub-gems ([#1715](https://github.com/cucumber/cucumber-ruby/pull/1715) [luke-hill](https://github.com/luke-hill))

examples/i18n/ca/lib/calculadora.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def add
1111
end
1212

1313
def divide
14-
@args[0].to_f / @args[1].to_f
14+
@args[0].to_f / @args[1]
1515
end
1616
end

examples/i18n/cs/lib/calculator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def add
1111
end
1212

1313
def divide
14-
@args[0].to_f / @args[1].to_f
14+
@args[0].to_f / @args[1]
1515
end
1616
end

examples/i18n/de/lib/calculator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def add
1111
end
1212

1313
def divide
14-
@args[0].to_f / @args[1].to_f
14+
@args[0].to_f / @args[1]
1515
end
1616
end

examples/i18n/el/lib/calculator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def add
1111
end
1212

1313
def divide
14-
@args[0].to_f / @args[1].to_f
14+
@args[0].to_f / @args[1]
1515
end
1616
end

examples/i18n/en/lib/calculator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def add
1111
end
1212

1313
def divide
14-
@args[0].to_f / @args[1].to_f
14+
@args[0].to_f / @args[1]
1515
end
1616
end

examples/i18n/eo/lib/calculator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def add
1111
end
1212

1313
def divide
14-
@args[0].to_f / @args[1].to_f
14+
@args[0].to_f / @args[1]
1515
end
1616
end

examples/i18n/es/lib/calculador.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def add
1111
end
1212

1313
def divide
14-
@args[0].to_f / @args[1].to_f
14+
@args[0].to_f / @args[1]
1515
end
1616
end

examples/i18n/et/lib/kalkulaator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def liida
1111
end
1212

1313
def jaga
14-
@args[0].to_f / @args[1].to_f
14+
@args[0].to_f / @args[1]
1515
end
1616
end

0 commit comments

Comments
 (0)