Skip to content

Commit 439da14

Browse files
committed
[rb] fix new linting failures
1 parent 8ef7001 commit 439da14

21 files changed

Lines changed: 199 additions & 33 deletions

File tree

rb/.rubocop.yml

Lines changed: 167 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ AllCops:
66
TargetRubyVersion: 2.7
77
Exclude:
88
- 'lib/selenium/devtools/**/*'
9-
NewCops: enable
109

1110
Layout/EmptyLinesAroundAttributeAccessor:
1211
Enabled: true
@@ -18,7 +17,7 @@ Layout/EmptyLinesAroundModuleBody:
1817
Enabled: false
1918

2019
Layout/LineLength:
21-
IgnoredPatterns:
20+
AllowedPatterns:
2221
- '\s+# rubocop'
2322
- '^\s*#'
2423
- '^\s*it .*, except: \{.*\} do$'
@@ -190,3 +189,169 @@ Style/SignalException:
190189

191190
RSpec/BeEq:
192191
Enabled: false
192+
193+
# Additional things
194+
Gemspec/DateAssignment: # new in 1.10
195+
Enabled: true
196+
Gemspec/RequireMFA: # new in 1.23
197+
Enabled: true
198+
Layout/LineEndStringConcatenationIndentation: # new in 1.18
199+
Enabled: true
200+
Layout/SpaceBeforeBrackets: # new in 1.7
201+
Enabled: true
202+
Lint/AmbiguousAssignment: # new in 1.7
203+
Enabled: true
204+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
205+
Enabled: true
206+
Lint/AmbiguousRange: # new in 1.19
207+
Enabled: true
208+
Lint/DeprecatedConstants: # new in 1.8
209+
Enabled: true
210+
Lint/DuplicateBranch: # new in 1.3
211+
Enabled: true
212+
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
213+
Enabled: true
214+
Lint/EmptyBlock: # new in 1.1
215+
Enabled: true
216+
Lint/EmptyClass: # new in 1.3
217+
Enabled: true
218+
Lint/EmptyInPattern: # new in 1.16
219+
Enabled: true
220+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
221+
Enabled: true
222+
Lint/LambdaWithoutLiteralBlock: # new in 1.8
223+
Enabled: true
224+
Lint/NoReturnInBeginEndBlocks: # new in 1.2
225+
Enabled: true
226+
Lint/NumberedParameterAssignment: # new in 1.9
227+
Enabled: true
228+
Lint/OrAssignmentToConstant: # new in 1.9
229+
Enabled: true
230+
Lint/RedundantDirGlobSort: # new in 1.8
231+
Enabled: true
232+
Lint/RefinementImportMethods: # new in 1.27
233+
Enabled: true
234+
Lint/RequireRelativeSelfPath: # new in 1.22
235+
Enabled: true
236+
Lint/SymbolConversion: # new in 1.9
237+
Enabled: true
238+
Lint/ToEnumArguments: # new in 1.1
239+
Enabled: true
240+
Lint/TripleQuotes: # new in 1.9
241+
Enabled: true
242+
Lint/UnexpectedBlockArity: # new in 1.5
243+
Enabled: true
244+
Lint/UnmodifiedReduceAccumulator: # new in 1.1
245+
Enabled: true
246+
Lint/UselessRuby2Keywords: # new in 1.23
247+
Enabled: true
248+
Naming/BlockForwarding: # new in 1.24
249+
Enabled: true
250+
Security/CompoundHash: # new in 1.28
251+
Enabled: true
252+
Security/IoMethods: # new in 1.22
253+
Enabled: true
254+
Style/ArgumentsForwarding: # new in 1.1
255+
Enabled: true
256+
Style/CollectionCompact: # new in 1.2
257+
Enabled: true
258+
Style/DocumentDynamicEvalDefinition: # new in 1.1
259+
Enabled: true
260+
Style/EndlessMethod: # new in 1.8
261+
Enabled: true
262+
Style/FetchEnvVar: # new in 1.28
263+
Enabled: true
264+
Style/FileRead: # new in 1.24
265+
Enabled: true
266+
Style/FileWrite: # new in 1.24
267+
Enabled: true
268+
Style/HashConversion: # new in 1.10
269+
Enabled: true
270+
Style/HashExcept: # new in 1.7
271+
Enabled: true
272+
Style/IfWithBooleanLiteralBranches: # new in 1.9
273+
Enabled: true
274+
Style/InPatternThen: # new in 1.16
275+
Enabled: true
276+
Style/MapToHash: # new in 1.24
277+
Enabled: true
278+
Style/MultilineInPatternThen: # new in 1.16
279+
Enabled: true
280+
Style/NegatedIfElseCondition: # new in 1.2
281+
Enabled: true
282+
Style/NestedFileDirname: # new in 1.26
283+
Enabled: true
284+
Style/NilLambda: # new in 1.3
285+
Enabled: true
286+
Style/NumberedParameters: # new in 1.22
287+
Enabled: true
288+
Style/NumberedParametersLimit: # new in 1.22
289+
Enabled: true
290+
Style/ObjectThen: # new in 1.28
291+
Enabled: true
292+
Style/OpenStructUse: # new in 1.23
293+
Enabled: true
294+
Style/QuotedSymbols: # new in 1.16
295+
Enabled: true
296+
Style/RedundantArgument: # new in 1.4
297+
Enabled: true
298+
Style/RedundantInitialize: # new in 1.27
299+
Enabled: true
300+
Style/RedundantSelfAssignmentBranch: # new in 1.19
301+
Enabled: true
302+
Style/SelectByRegexp: # new in 1.22
303+
Enabled: true
304+
Style/StringChars: # new in 1.12
305+
Enabled: true
306+
Style/SwapValues: # new in 1.1
307+
Enabled: true
308+
Performance/AncestorsInclude: # new in 1.7
309+
Enabled: true
310+
Performance/BigDecimalWithNumericArgument: # new in 1.7
311+
Enabled: true
312+
Performance/BlockGivenWithExplicitBlock: # new in 1.9
313+
Enabled: true
314+
Performance/CollectionLiteralInLoop: # new in 1.8
315+
Enabled: true
316+
Performance/ConcurrentMonotonicTime: # new in 1.12
317+
Enabled: true
318+
Performance/ConstantRegexp: # new in 1.9
319+
Enabled: true
320+
Performance/MapCompact: # new in 1.11
321+
Enabled: true
322+
Performance/MethodObjectAsBlock: # new in 1.9
323+
Enabled: true
324+
Performance/RedundantEqualityComparisonBlock: # new in 1.10
325+
Enabled: true
326+
Performance/RedundantSortBlock: # new in 1.7
327+
Enabled: true
328+
Performance/RedundantSplitRegexpArgument: # new in 1.10
329+
Enabled: true
330+
Performance/RedundantStringChars: # new in 1.7
331+
Enabled: true
332+
Performance/ReverseFirst: # new in 1.7
333+
Enabled: true
334+
Performance/SortReverse: # new in 1.7
335+
Enabled: true
336+
Performance/Squeeze: # new in 1.7
337+
Enabled: true
338+
Performance/StringIdentifierArgument: # new in 1.13
339+
Enabled: true
340+
Performance/StringInclude: # new in 1.7
341+
Enabled: true
342+
Performance/Sum: # new in 1.8
343+
Enabled: true
344+
RSpec/BeNil: # new in 2.9.0
345+
Enabled: true
346+
RSpec/ExcessiveDocstringSpacing: # new in 2.5
347+
Enabled: true
348+
RSpec/IdenticalEqualityAssertion: # new in 2.4
349+
Enabled: true
350+
RSpec/SubjectDeclaration: # new in 2.5
351+
Enabled: true
352+
RSpec/VerifiedDoubleReference: # new in 2.10.0
353+
Enabled: true
354+
RSpec/FactoryBot/SyntaxMethods: # new in 2.7
355+
Enabled: true
356+
RSpec/Rails/AvoidSetupHook: # new in 2.4
357+
Enabled: true

rb/lib/selenium/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def available_assets
122122
end
123123

124124
def net_http_start(address, &block)
125-
http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
125+
http_proxy = ENV.fetch('http_proxy', nil) || ENV.fetch('HTTP_PROXY', nil)
126126
if http_proxy
127127
http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?('http://')
128128
uri = URI.parse(http_proxy)

rb/lib/selenium/webdriver/common/element.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def ==(other)
4646
alias_method :eql?, :==
4747

4848
def hash
49-
@id.hash ^ @bridge.hash
49+
[@id, @bridge].hash
5050
end
5151

5252
#

rb/lib/selenium/webdriver/common/platform.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ def find_binary(*binary_names)
177177

178178
def find_in_program_files(*binary_names)
179179
paths = [
180-
ENV['PROGRAMFILES'] || '\\Program Files',
181-
ENV['ProgramFiles(x86)'] || '\\Program Files (x86)',
182-
ENV['ProgramW6432'] || '\\Program Files'
180+
ENV.fetch('PROGRAMFILES', '\\Program Files'),
181+
ENV.fetch('ProgramFiles(x86)', '\\Program Files (x86)'),
182+
ENV.fetch('ProgramW6432', '\\Program Files')
183183
]
184184

185185
paths.each do |root|

rb/lib/selenium/webdriver/common/shadow_root.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def ==(other)
4545
alias_method :eql?, :==
4646

4747
def hash
48-
@id.hash ^ @bridge.hash
48+
[@id, @bridge].hash
4949
end
5050

5151
#

rb/lib/selenium/webdriver/firefox/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module Util
2727
def app_data_path
2828
case Platform.os
2929
when :windows
30-
"#{ENV['APPDATA']}\\Mozilla\\Firefox"
30+
"#{ENV.fetch('APPDATA')}\\Mozilla\\Firefox"
3131
when :macosx
3232
"#{Platform.home}/Library/Application Support/Firefox"
3333
when :unix, :linux

rb/lib/selenium/webdriver/remote/http/default.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ def new_http_client
136136

137137
def proxy
138138
@proxy ||= begin
139-
proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
140-
no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
139+
proxy = ENV.fetch('http_proxy', nil) || ENV.fetch('HTTP_PROXY', nil)
140+
no_proxy = ENV.fetch('no_proxy', nil) || ENV.fetch('NO_PROXY', nil)
141141

142142
if proxy
143143
proxy = "http://#{proxy}" unless proxy.start_with?('http://')

rb/lib/selenium/webdriver/support/color.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def ==(other)
125125
alias_method :eql?, :==
126126

127127
def hash
128-
[red, green, blue, alpha].hash ^ self.class.hash
128+
[red, green, blue, alpha, self.class].hash
129129
end
130130

131131
def rgb

rb/lib/selenium/webdriver/support/guards.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def add_message(name, message)
4848
def disposition
4949
if !skipping_guard.nil?
5050
[:skip, skipping_guard.message]
51-
elsif !pending_guard.nil? && ENV['SKIP_PENDING']
51+
elsif !pending_guard.nil? && ENV.fetch('SKIP_PENDING', nil)
5252
[:skip, pending_guard.message]
5353
elsif !pending_guard.nil?
5454
[:pending, pending_guard.message]

rb/spec/integration/selenium/webdriver/chrome/profile_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module Chrome
3939

4040
profile.add_extension(ext_path)
4141

42-
ext_file = instance_double('file')
42+
ext_file = instance_double(File)
4343
allow(File).to receive(:open).with(ext_path, 'rb').and_yield ext_file
4444
allow(ext_file).to receive(:read).and_return 'test'
4545

0 commit comments

Comments
 (0)