Skip to content

Commit 8e519a5

Browse files
authored
Refactor/manual cops part1 (#1739)
* Partial manual fix of RSpec/ContextWording * Partial example length fixes * Fix up some ExampleLength issues * Improve ExampleLength to treat all long objects as single line counts * Partial fix of multiple expectations * Fix global var offenses * Fix: RSpec/IteratedExpectation * Configure setting for message spy cop * Add some notes about stylistic preferences and re-enable some disabled cops to be introduced to auto-gen file * Update auto-gen-config file * Remove a redundant spec in step match search * Re-gen the auto-gen-config file * Fix missing param by replacing with a double * Fix up line number references in json spec
1 parent 4c69bee commit 8e519a5

22 files changed

+589
-601
lines changed

.rubocop.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ AllCops:
2525
Layout/EndOfLine:
2626
EnforcedStyle: lf
2727

28+
# A line length of 200 covers most violations in the repo while still being a more up to date length given today's screen sizes
29+
Layout/LineLength:
30+
Max: 200
31+
2832
# Reviewed: Formatters put trailing spaces after things like 'Feature: '
2933
# In pretty_spec.rb & progress_spec.rb offences look false as the trailing spaces are in fact multiline string literals
3034
Layout/TrailingWhitespace:
@@ -71,10 +75,6 @@ Metrics/ClassLength:
7175
# TODO: Manually added! - be careful with regenning the file - this needs a fix
7276
- lib/cucumber/formatter/pretty.rb
7377

74-
# A line length of 200 covers most violations in the repo while still being a more up to date length given today's screen sizes
75-
Layout/LineLength:
76-
Max: 200
77-
7878
# TODO: [LH] - Initial 10% reduction done Aug '23 - Further reductions should happen as/when we fix a bunch of the todo
7979
Metrics/ModuleLength:
8080
Max: 135
@@ -102,8 +102,6 @@ Naming/AsciiIdentifiers:
102102
# For the most part, the project is solid on naming. There are though, a few
103103
# cases where the cop doesn't need to catch.
104104
Naming/MethodName:
105-
EnforcedStyle: snake_case
106-
Enabled: true
107105
Exclude:
108106
- 'examples/i18n/ar/lib/calculator.rb'
109107
- 'examples/i18n/he/lib/calculator.rb'
@@ -129,20 +127,21 @@ Naming/VariableNumber:
129127
Exclude:
130128
- 'examples/i18n/**/*'
131129

132-
# This cop throws errors when parsing a lot of the repo's code, possibly due
133-
# to splat issues?
134-
Style/AccessModifierDeclarations:
135-
Enabled: false
130+
RSpec/ExampleLength:
131+
CountAsOne: ['array', 'hash', 'heredoc']
136132

133+
# Stylistic preference for cucumber
134+
RSpec/MessageSpies:
135+
EnforcedStyle: receive
136+
137+
# Stylistic preference for cucumber
137138
Style/Documentation:
138139
Enabled: false
139140

140141
Style/FormatStringToken:
141142
EnforcedStyle: annotated
142143

143-
Style/StderrPuts:
144-
Enabled: false
145-
144+
# Stylistic preference for cucumber
146145
Style/RegexpLiteral:
147146
EnforcedStyle: slashes
148147
AllowInnerSlashes: true

.rubocop_todo.yml

Lines changed: 83 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-09-07 08:42:40 UTC using RuboCop version 1.56.2.
3+
# on 2023-09-12 16:42:15 UTC using RuboCop version 1.56.3.
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
77
# versions of RuboCop, may require this file to be generated again.
88

99
# TODO - [LH] -> Aug '23 - 370 files inspected, 1110 offenses detected, 482 offenses autocorrectable
1010
# TODO - [LH] -> Sep 6 '23 - 370 files inspected, 983 offenses detected, 368 offenses autocorrectable
11+
# TODO - [LH] -> Sep 11 '23 - 370 files inspected, 825 offenses detected, 387 offenses autocorrectable
12+
13+
# Offense count: 1
14+
# This cop supports safe autocorrection (--autocorrect).
15+
# Configuration parameters: EnforcedStyleAlignWith.
16+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
17+
Layout/BlockAlignment:
18+
Exclude:
19+
- 'spec/cucumber/formatter/fail_fast_spec.rb'
20+
21+
# Offense count: 17
22+
# This cop supports safe autocorrection (--autocorrect).
23+
Layout/ClosingHeredocIndentation:
24+
Exclude:
25+
- 'spec/cucumber/cli/profile_loader_spec.rb'
26+
- 'spec/cucumber/formatter/json_spec.rb'
27+
28+
# Offense count: 1
29+
# This cop supports safe autocorrection (--autocorrect).
30+
Layout/EmptyLines:
31+
Exclude:
32+
- 'spec/cucumber/formatter/fail_fast_spec.rb'
1133

1234
# Offense count: 38
1335
# This cop supports safe autocorrection (--autocorrect).
@@ -22,12 +44,28 @@ Layout/HashAlignment:
2244
- 'lib/cucumber/formatter/ansicolor.rb'
2345
- 'lib/cucumber/gherkin/formatter/ansi_escapes.rb'
2446

25-
# Offense count: 2
47+
# Offense count: 4
2648
# This cop supports safe autocorrection (--autocorrect).
2749
Layout/HeredocIndentation:
2850
Exclude:
2951
- 'lib/cucumber/cli/options.rb'
3052
- 'lib/cucumber/cli/profile_loader.rb'
53+
- 'spec/cucumber/cli/profile_loader_spec.rb'
54+
55+
# Offense count: 3
56+
# This cop supports safe autocorrection (--autocorrect).
57+
# Configuration parameters: EnforcedStyle.
58+
# SupportedStyles: normal, indented_internal_methods
59+
Layout/IndentationConsistency:
60+
Exclude:
61+
- 'spec/cucumber/formatter/fail_fast_spec.rb'
62+
63+
# Offense count: 1
64+
# This cop supports safe autocorrection (--autocorrect).
65+
# Configuration parameters: Width, AllowedPatterns.
66+
Layout/IndentationWidth:
67+
Exclude:
68+
- 'spec/cucumber/formatter/fail_fast_spec.rb'
3169

3270
# Offense count: 1
3371
# This cop supports safe autocorrection (--autocorrect).
@@ -41,12 +79,6 @@ Lint/SuppressedException:
4179
Exclude:
4280
- 'lib/cucumber/rake/task.rb'
4381

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-
5082
# Offense count: 9
5183
# Configuration parameters: AllowedMethods, AllowedPatterns.
5284
Metrics/CyclomaticComplexity:
@@ -77,11 +109,19 @@ RSpec/Capybara/FeatureMethods:
77109
Exclude:
78110
- 'spec/cucumber/filters/activate_steps_spec.rb'
79111

80-
# Offense count: 85
112+
# Offense count: 15
81113
# Configuration parameters: Prefixes, AllowedPatterns.
82114
# Prefixes: when, with, without
83115
RSpec/ContextWording:
84-
Enabled: false
116+
Exclude:
117+
- 'spec/cucumber/cli/options_spec.rb'
118+
- 'spec/cucumber/cli/rerun_spec.rb'
119+
- 'spec/cucumber/configuration_spec.rb'
120+
- 'spec/cucumber/filters/tag_limits_spec.rb'
121+
- 'spec/cucumber/formatter/http_io_spec.rb'
122+
- 'spec/cucumber/formatter/junit_spec.rb'
123+
- 'spec/cucumber/formatter/publish_banner_printer_spec.rb'
124+
- 'spec/cucumber/glue/step_definition_spec.rb'
85125

86126
# Offense count: 1
87127
# Configuration parameters: IgnoredMetadata.
@@ -94,15 +134,15 @@ RSpec/DescribeClass:
94134
- '**/spec/views/**/*'
95135
- 'spec/cck/cck_spec.rb'
96136

97-
# Offense count: 18
137+
# Offense count: 8
98138
# This cop supports unsafe autocorrection (--autocorrect-all).
99139
# Configuration parameters: SkipBlocks, EnforcedStyle.
100140
# SupportedStyles: described_class, explicit
101141
RSpec/DescribedClass:
102142
Exclude:
103-
- 'spec/cucumber/formatter/interceptor_spec.rb'
143+
- 'spec/cucumber/cli/profile_loader_spec.rb'
144+
- 'spec/cucumber/formatter/json_spec.rb'
104145
- 'spec/cucumber/multiline_argument/data_table_spec.rb'
105-
- 'spec/cucumber/runtime/support_code_spec.rb'
106146

107147
# Offense count: 2
108148
# This cop supports unsafe autocorrection (--autocorrect-all).
@@ -119,12 +159,12 @@ RSpec/EmptyLineAfterFinalLet:
119159
- 'spec/cucumber/configuration_spec.rb'
120160
- 'spec/cucumber/hooks_spec.rb'
121161

122-
# Offense count: 150
162+
# Offense count: 101
123163
# Configuration parameters: CountAsOne.
124164
RSpec/ExampleLength:
125165
Max: 58
126166

127-
# Offense count: 4
167+
# Offense count: 1
128168
# This cop supports safe autocorrection (--autocorrect).
129169
# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples.
130170
# DisallowedExamples: works
@@ -146,54 +186,32 @@ RSpec/ExpectInHook:
146186
- 'spec/cucumber/multiline_argument/data_table_spec.rb'
147187
- 'spec/cucumber/runtime/meta_message_builder_spec.rb'
148188

149-
# Offense count: 9
189+
# Offense count: 6
150190
RSpec/ExpectOutput:
151191
Exclude:
152192
- 'spec/cucumber/formatter/interceptor_spec.rb'
153193

154-
# Offense count: 71
194+
# Offense count: 62
155195
# This cop supports safe autocorrection (--autocorrect).
156196
# Configuration parameters: EnforcedStyle.
157197
# SupportedStyles: implicit, each, example
158198
RSpec/HookArgument:
159199
Enabled: false
160200

161-
# Offense count: 4
162-
# This cop supports safe autocorrection (--autocorrect).
163-
RSpec/HooksBeforeExamples:
164-
Exclude:
165-
- 'spec/cucumber/formatter/interceptor_spec.rb'
166-
167201
# Offense count: 15
168202
# Configuration parameters: AssignmentOnly.
169203
RSpec/InstanceVariable:
170204
Exclude:
171205
- 'spec/cucumber/formatter/http_io_spec.rb'
172206

173-
# Offense count: 1
174-
RSpec/IteratedExpectation:
175-
Exclude:
176-
- 'spec/cucumber/filters/gated_receiver_spec.rb'
177-
178-
# Offense count: 59
207+
# Offense count: 6
179208
# Configuration parameters: EnforcedStyle.
180209
# SupportedStyles: have_received, receive
181210
RSpec/MessageSpies:
182211
Exclude:
183-
- 'spec/cucumber/cli/configuration_spec.rb'
184-
- 'spec/cucumber/cli/main_spec.rb'
185-
- 'spec/cucumber/cli/options_spec.rb'
186-
- 'spec/cucumber/filters/activate_steps_spec.rb'
187-
- 'spec/cucumber/filters/gated_receiver_spec.rb'
188-
- 'spec/cucumber/filters/retry_spec.rb'
189-
- 'spec/cucumber/filters/tag_limits_spec.rb'
190-
- 'spec/cucumber/formatter/interceptor_spec.rb'
191-
- 'spec/cucumber/glue/registry_and_more_spec.rb'
192-
- 'spec/cucumber/glue/step_definition_spec.rb'
193-
- 'spec/cucumber/project_initializer_spec.rb'
194-
- 'spec/cucumber/runtime/meta_message_builder_spec.rb'
195-
- 'spec/cucumber/step_match_search_spec.rb'
196-
- 'spec/cucumber/world/pending_spec.rb'
212+
- 'spec/cucumber/deprecate_spec.rb'
213+
- 'spec/cucumber/formatter/http_io_spec.rb'
214+
- 'spec/cucumber/runtime/hooks_examples.rb'
197215

198216
# Offense count: 15
199217
RSpec/MissingExampleGroupArgument:
@@ -202,11 +220,11 @@ RSpec/MissingExampleGroupArgument:
202220
- 'spec/cucumber/formatter/fail_fast_spec.rb'
203221
- 'spec/cucumber/formatter/rerun_spec.rb'
204222

205-
# Offense count: 90
223+
# Offense count: 87
206224
RSpec/MultipleExpectations:
207225
Max: 8
208226

209-
# Offense count: 37
227+
# Offense count: 38
210228
# Configuration parameters: AllowSubject.
211229
RSpec/MultipleMemoizedHelpers:
212230
Max: 15
@@ -254,10 +272,9 @@ RSpec/RepeatedExample:
254272
- 'spec/cucumber/formatter/rerun_spec.rb'
255273
- 'spec/cucumber/world/pending_spec.rb'
256274

257-
# Offense count: 4
275+
# Offense count: 2
258276
RSpec/RepeatedExampleGroupDescription:
259277
Exclude:
260-
- 'spec/cucumber/formatter/interceptor_spec.rb'
261278
- 'spec/cucumber/glue/proto_world_spec.rb'
262279

263280
# Offense count: 31
@@ -283,12 +300,6 @@ RSpec/ScatteredLet:
283300
Exclude:
284301
- 'spec/cucumber/runtime/support_code_spec.rb'
285302

286-
# Offense count: 2
287-
# This cop supports safe autocorrection (--autocorrect).
288-
RSpec/ScatteredSetup:
289-
Exclude:
290-
- 'spec/cucumber/formatter/interceptor_spec.rb'
291-
292303
# Offense count: 9
293304
RSpec/StubbedMock:
294305
Exclude:
@@ -334,3 +345,22 @@ Style/ClassAndModuleChildren:
334345
Style/ClassVars:
335346
Exclude:
336347
- 'spec/cucumber/glue/step_definition_spec.rb'
348+
349+
# Offense count: 6
350+
# This cop supports safe autocorrection (--autocorrect).
351+
Style/StderrPuts:
352+
Exclude:
353+
- 'examples/i18n/Rakefile'
354+
- 'lib/cucumber/cli/main.rb'
355+
- 'lib/cucumber/deprecate.rb'
356+
- 'lib/cucumber/formatter/unicode.rb'
357+
- 'lib/cucumber/rake/task.rb'
358+
- 'spec/cucumber/formatter/interceptor_spec.rb'
359+
360+
# Offense count: 1
361+
# This cop supports safe autocorrection (--autocorrect).
362+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
363+
# SupportedStyles: single_quotes, double_quotes
364+
Style/StringLiterals:
365+
Exclude:
366+
- 'spec/cucumber/cli/options_spec.rb'

0 commit comments

Comments
 (0)