Skip to content

Commit fa682a1

Browse files
committed
rb - update conditional formatting
1 parent 26ce4eb commit fa682a1

38 files changed

+119
-240
lines changed

rb/.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ Style/SpaceInsideHashLiteralBraces:
88

99
Style/BracesAroundHashParameters:
1010
EnforcedStyle: context_dependent
11+
12+
Lint/AssignmentInCondition:
13+
Enabled: false

rb/.rubocop_todo.yml

Lines changed: 8 additions & 109 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 2016-06-08 15:50:57 -0700 using RuboCop version 0.37.2.
3+
# on 2016-06-08 18:56:38 -0700 using RuboCop version 0.37.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
@@ -11,34 +11,12 @@ Lint/AmbiguousRegexpLiteral:
1111
Exclude:
1212
- 'spec/integration/selenium/webdriver/firefox/marionette_spec.rb'
1313

14-
# Offense count: 12
15-
# Configuration parameters: AllowSafeAssignment.
16-
Lint/AssignmentInCondition:
17-
Exclude:
18-
- 'lib/selenium/webdriver/common/bridge_helper.rb'
19-
- 'lib/selenium/webdriver/common/options.rb'
20-
- 'lib/selenium/webdriver/common/search_context.rb'
21-
- 'lib/selenium/webdriver/firefox/binary.rb'
22-
- 'lib/selenium/webdriver/firefox/profiles_ini.rb'
23-
- 'lib/selenium/webdriver/remote/bridge.rb'
24-
- 'lib/selenium/webdriver/remote/http/default.rb'
25-
- 'lib/selenium/webdriver/remote/http/persistent.rb'
26-
- 'lib/selenium/webdriver/remote/response.rb'
27-
- 'lib/selenium/webdriver/safari/server.rb'
28-
2914
# Offense count: 2
3015
# Cop supports --auto-correct.
3116
Lint/DeprecatedClassMethods:
3217
Exclude:
3318
- 'lib/selenium/server.rb'
3419

35-
# Offense count: 1
36-
# Cop supports --auto-correct.
37-
# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
38-
# SupportedStyles: keyword, variable, start_of_line
39-
Lint/EndAlignment:
40-
Enabled: false
41-
4220
# Offense count: 10
4321
Lint/HandleExceptions:
4422
Exclude:
@@ -51,11 +29,6 @@ Lint/HandleExceptions:
5129
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
5230
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
5331

54-
# Offense count: 1
55-
Lint/IneffectiveAccessModifier:
56-
Exclude:
57-
- 'lib/selenium/server.rb'
58-
5932
# Offense count: 5
6033
# Cop supports --auto-correct.
6134
# Configuration parameters: IgnoreEmptyBlocks.
@@ -95,19 +68,19 @@ Metrics/AbcSize:
9568
# Offense count: 13
9669
# Configuration parameters: CountComments.
9770
Metrics/ClassLength:
98-
Max: 428
71+
Max: 427
9972

10073
# Offense count: 24
10174
Metrics/CyclomaticComplexity:
102-
Max: 17
75+
Max: 16
10376

104-
# Offense count: 721
77+
# Offense count: 717
10578
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
10679
# URISchemes: http, https
10780
Metrics/LineLength:
10881
Max: 318
10982

110-
# Offense count: 62
83+
# Offense count: 61
11184
# Configuration parameters: CountComments.
11285
Metrics/MethodLength:
11386
Max: 37
@@ -119,7 +92,7 @@ Metrics/ModuleLength:
11992

12093
# Offense count: 15
12194
Metrics/PerceivedComplexity:
122-
Max: 17
95+
Max: 16
12396

12497
# Offense count: 1
12598
# Cop supports --auto-correct.
@@ -186,26 +159,6 @@ Style/AlignParameters:
186159
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
187160
- 'spec/unit/selenium/webdriver/remote/http/common_spec.rb'
188161

189-
# Offense count: 13
190-
# Cop supports --auto-correct.
191-
# Configuration parameters: EnforcedStyle, SupportedStyles.
192-
# SupportedStyles: always, conditionals
193-
Style/AndOr:
194-
Exclude:
195-
- 'lib/selenium/webdriver/chrome.rb'
196-
- 'lib/selenium/webdriver/common/bridge_helper.rb'
197-
- 'lib/selenium/webdriver/common/driver_extensions/uploads_files.rb'
198-
- 'lib/selenium/webdriver/common/keys.rb'
199-
- 'lib/selenium/webdriver/edge.rb'
200-
- 'lib/selenium/webdriver/firefox.rb'
201-
- 'lib/selenium/webdriver/ie.rb'
202-
- 'lib/selenium/webdriver/phantomjs.rb'
203-
- 'lib/selenium/webdriver/remote/bridge.rb'
204-
- 'lib/selenium/webdriver/remote/http/common.rb'
205-
- 'lib/selenium/webdriver/remote/response.rb'
206-
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
207-
- 'lib/selenium/webdriver/support/select.rb'
208-
209162
# Offense count: 3
210163
Style/AsciiComments:
211164
Exclude:
@@ -229,13 +182,6 @@ Style/BarePercentLiterals:
229182
Style/BlockDelimiters:
230183
Enabled: false
231184

232-
# Offense count: 3
233-
# Cop supports --auto-correct.
234-
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth.
235-
# SupportedStyles: case, end
236-
Style/CaseIndentation:
237-
Enabled: false
238-
239185
# Offense count: 5
240186
# Configuration parameters: EnforcedStyle, SupportedStyles.
241187
# SupportedStyles: nested, compact
@@ -278,17 +224,6 @@ Style/CommentIndentation:
278224
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
279225
- 'spec/integration/selenium/webdriver/target_locator_spec.rb'
280226

281-
# Offense count: 3
282-
# Cop supports --auto-correct.
283-
# Configuration parameters: SingleLineConditionsOnly.
284-
Style/ConditionalAssignment:
285-
Exclude:
286-
- 'lib/selenium/webdriver/common/*'
287-
- 'lib/selenium/webdriver/firefox/*'
288-
- 'lib/selenium/webdriver/remote/*'
289-
- 'lib/selenium/webdriver/support/event_firing_bridge.rb'
290-
- 'spec/integration/selenium/webdriver/spec_support/rack_server.rb'
291-
292227
# Offense count: 1
293228
Style/ConstantName:
294229
Exclude:
@@ -318,19 +253,6 @@ Style/Documentation:
318253
Style/DotPosition:
319254
Enabled: false
320255

321-
# Offense count: 12
322-
Style/DoubleNegation:
323-
Exclude:
324-
- 'lib/selenium/webdriver/chrome/bridge.rb'
325-
- 'lib/selenium/webdriver/common/file_reaper.rb'
326-
- 'lib/selenium/webdriver/common/platform.rb'
327-
- 'lib/selenium/webdriver/common/socket_lock.rb'
328-
- 'lib/selenium/webdriver/remote/http/curb.rb'
329-
- 'lib/selenium/webdriver/safari/options.rb'
330-
- 'spec/integration/selenium/webdriver/spec_helper.rb'
331-
- 'spec/integration/selenium/webdriver/spec_support/guards.rb'
332-
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
333-
334256
# Offense count: 17
335257
# Cop supports --auto-correct.
336258
# Configuration parameters: AllowAdjacentOneLineDefs.
@@ -416,21 +338,6 @@ Style/FormatString:
416338
- 'lib/selenium/webdriver/safari/server.rb'
417339
- 'lib/selenium/webdriver/support/color.rb'
418340

419-
# Offense count: 14
420-
# Cop supports --auto-correct.
421-
# Configuration parameters: MaxLineLength.
422-
Style/IfUnlessModifier:
423-
Exclude:
424-
- 'lib/selenium/server.rb'
425-
- 'lib/selenium/webdriver/common/driver.rb'
426-
- 'lib/selenium/webdriver/edge/legacy_support.rb'
427-
- 'lib/selenium/webdriver/remote/bridge.rb'
428-
- 'lib/selenium/webdriver/remote/response.rb'
429-
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
430-
- 'selenium-webdriver.gemspec'
431-
- 'spec/integration/selenium/webdriver/spec_helper.rb'
432-
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
433-
434341
# Offense count: 1
435342
# Cop supports --auto-correct.
436343
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
@@ -446,7 +353,7 @@ Style/IndentationConsistency:
446353
Exclude:
447354
- 'spec/unit/selenium/webdriver/remote/http/default_spec.rb'
448355

449-
# Offense count: 4
356+
# Offense count: 8
450357
# Cop supports --auto-correct.
451358
# Configuration parameters: Width.
452359
Style/IndentationWidth:
@@ -508,14 +415,6 @@ Style/MultilineOperationIndentation:
508415
Style/MutableConstant:
509416
Enabled: false
510417

511-
# Offense count: 1
512-
# Cop supports --auto-correct.
513-
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
514-
# SupportedStyles: skip_modifier_ifs, always
515-
Style/Next:
516-
Exclude:
517-
- 'lib/selenium/webdriver/firefox/profile.rb'
518-
519418
# Offense count: 2
520419
# Cop supports --auto-correct.
521420
Style/Not:
@@ -695,7 +594,7 @@ Style/SpaceInsideStringInterpolation:
695594
Style/SpecialGlobalVars:
696595
EnforcedStyle: use_perl_names
697596

698-
# Offense count: 1418
597+
# Offense count: 1417
699598
# Cop supports --auto-correct.
700599
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
701600
# SupportedStyles: single_quotes, double_quotes

rb/lib/selenium/server.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ def download(required_version)
7171
required_version = latest if required_version == :latest
7272
download_file_name = "selenium-server-standalone-#{required_version}.jar"
7373

74-
if File.exists? download_file_name
75-
return download_file_name
76-
end
74+
return download_file_name if File.exists? download_file_name
7775

7876
begin
7977
open(download_file_name, "wb") do |destination|

rb/lib/selenium/webdriver/chrome.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def self.driver_path=(path)
3636
def self.driver_path
3737
@driver_path ||= begin
3838
path = Platform.find_binary("chromedriver")
39-
path or raise Error::WebDriverError, MISSING_TEXT
39+
raise Error::WebDriverError, MISSING_TEXT unless path
4040
Platform.assert_executable path
4141

4242
path

rb/lib/selenium/webdriver/chrome/bridge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def create_capabilities(opts)
107107
chrome_options['binary'] = Chrome.path if Chrome.path
108108
chrome_options['nativeEvents'] = true if native_events
109109
chrome_options['verbose'] = true if verbose
110-
chrome_options['detach'] = detach.nil? || !!detach
110+
chrome_options['detach'] = detach != false
111111
chrome_options['noWebsiteTestingDefaults'] = true if no_website_testing_defaults
112112
chrome_options['prefs'] = prefs if prefs
113113

rb/lib/selenium/webdriver/chrome/service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def start_process
3434
server_command = [@executable_path, "--port=#{@port}", *@extra_args]
3535
@process = ChildProcess.build(*server_command)
3636

37-
@process.io.inherit! if $DEBUG == true
37+
@process.io.inherit! if $DEBUG
3838
@process.start
3939
end
4040

rb/lib/selenium/webdriver/common/action_builder.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ def double_click(element = nil)
252252
#
253253

254254
def move_to(element, right_by = nil, down_by = nil)
255-
if right_by && down_by
256-
@actions << [:mouse, :move_to, [element, Integer(right_by), Integer(down_by)]]
257-
else
258-
@actions << [:mouse, :move_to, [element]]
259-
end
255+
@actions << if right_by && down_by
256+
[:mouse, :move_to, [element, Integer(right_by), Integer(down_by)]]
257+
else
258+
[:mouse, :move_to, [element]]
259+
end
260260

261261
self
262262
end

rb/lib/selenium/webdriver/common/bridge_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def unwrap_script_result(arg)
4444
end
4545

4646
def element_id_from(id)
47-
id['ELEMENT'] or id['element-6066-11e4-a52e-4f735466cecf']
47+
id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
4848
end
4949

5050
def parse_cookie_string(str)

rb/lib/selenium/webdriver/common/driver.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ def execute_async_script(script, *args)
272272
#
273273

274274
def [](sel)
275-
if sel.kind_of?(String) || sel.kind_of?(Symbol)
276-
sel = {id: sel}
277-
end
275+
sel = {id: sel} if sel.kind_of?(String) || sel.kind_of?(Symbol)
278276

279277
find_element sel
280278
end

rb/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module UploadsFiles
5252
#
5353

5454
def file_detector=(detector)
55-
unless detector.nil? or detector.respond_to? :call
55+
unless detector.nil? || detector.respond_to?(:call)
5656
raise ArgumentError, "detector must respond to #call"
5757
end
5858

0 commit comments

Comments
 (0)