Skip to content

Commit 274e9f2

Browse files
committed
rb - performance updates
1 parent fa682a1 commit 274e9f2

File tree

15 files changed

+31
-58
lines changed

15 files changed

+31
-58
lines changed

rb/.rubocop_todo.yml

Lines changed: 4 additions & 40 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 18:56:38 -0700 using RuboCop version 0.37.2.
3+
# on 2016-06-08 19:07:43 -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
@@ -68,13 +68,13 @@ Metrics/AbcSize:
6868
# Offense count: 13
6969
# Configuration parameters: CountComments.
7070
Metrics/ClassLength:
71-
Max: 427
71+
Max: 430
7272

7373
# Offense count: 24
7474
Metrics/CyclomaticComplexity:
7575
Max: 16
7676

77-
# Offense count: 717
77+
# Offense count: 716
7878
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
7979
# URISchemes: http, https
8080
Metrics/LineLength:
@@ -94,42 +94,6 @@ Metrics/ModuleLength:
9494
Metrics/PerceivedComplexity:
9595
Max: 16
9696

97-
# Offense count: 1
98-
# Cop supports --auto-correct.
99-
Performance/Casecmp:
100-
Exclude:
101-
- 'lib/selenium/webdriver/support/select.rb'
102-
103-
# Offense count: 1
104-
Performance/FixedSize:
105-
Exclude:
106-
- 'spec/integration/selenium/webdriver/driver_spec.rb'
107-
108-
# Offense count: 9
109-
# Cop supports --auto-correct.
110-
# Configuration parameters: MaxKeyValuePairs.
111-
Performance/RedundantMerge:
112-
Exclude:
113-
- 'lib/selenium/webdriver/chrome/bridge.rb'
114-
- 'lib/selenium/webdriver/edge/bridge.rb'
115-
- 'lib/selenium/webdriver/edge/legacy_support.rb'
116-
- 'lib/selenium/webdriver/firefox/bridge.rb'
117-
- 'lib/selenium/webdriver/phantomjs/bridge.rb'
118-
- 'lib/selenium/webdriver/remote/bridge.rb'
119-
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
120-
- 'lib/selenium/webdriver/safari/options.rb'
121-
122-
# Offense count: 6
123-
# Cop supports --auto-correct.
124-
Performance/StringReplacement:
125-
Exclude:
126-
- 'lib/selenium/webdriver/firefox/binary.rb'
127-
- 'lib/selenium/webdriver/remote/bridge.rb'
128-
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
129-
- 'lib/selenium/webdriver/safari/bridge.rb'
130-
- 'spec/integration/selenium/webdriver/element_spec.rb'
131-
- 'spec/integration/selenium/webdriver/spec_support/helpers.rb'
132-
13397
# Offense count: 31
13498
# Cop supports --auto-correct.
13599
# Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -594,7 +558,7 @@ Style/SpaceInsideStringInterpolation:
594558
Style/SpecialGlobalVars:
595559
EnforcedStyle: use_perl_names
596560

597-
# Offense count: 1417
561+
# Offense count: 1416
598562
# Cop supports --auto-correct.
599563
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
600564
# SupportedStyles: single_quotes, double_quotes

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def initialize(opts = {})
4343
desired_capabilities: caps
4444
}
4545

46-
remote_opts.merge!(http_client: http_client) if http_client
46+
remote_opts[:http_client] = http_client if http_client
4747

4848
super(remote_opts)
4949
end
@@ -100,8 +100,8 @@ def create_capabilities(opts)
100100
if profile
101101
data = profile.as_json
102102

103-
chrome_options.merge! 'profile' => data['zip'],
104-
'extensions' => data['extensions']
103+
chrome_options['profile'] = data['zip']
104+
chrome_options['extensions'] = data['extensions']
105105
end
106106

107107
chrome_options['binary'] = Chrome.path if Chrome.path

rb/lib/selenium/webdriver/edge/bridge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def initialize(opts = {})
4747
desired_capabilities: caps
4848
}
4949

50-
remote_opts.merge!(http_client: http_client) if http_client
50+
remote_opts[:http_client] = http_client if http_client
5151
super(remote_opts)
5252
end
5353

rb/lib/selenium/webdriver/edge/legacy_support.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ def mouseUp
6868
def mouseMoveTo(element, x = nil, y = nil)
6969
params = {element: element}
7070

71-
params.merge! xoffset: x, yoffset: y if x && y
71+
if x && y
72+
params[:xoffset] = x
73+
params[:yoffset] = y
74+
end
7275

7376
execute :mouseMoveTo, {}, params
7477
end

rb/lib/selenium/webdriver/firefox/binary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def start_with(profile, profile_path, *args)
3737
if Platform.cygwin?
3838
profile_path = Platform.cygwin_path(profile_path, windows: true)
3939
elsif Platform.windows?
40-
profile_path = profile_path.gsub("/", "\\")
40+
profile_path = profile_path.tr("/", "\\")
4141
end
4242

4343
ENV['XRE_CONSOLE_LOG'] = profile.log_file if profile.log_file

rb/lib/selenium/webdriver/firefox/bridge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def initialize(opts = {})
4949
desired_capabilities: caps
5050
}
5151

52-
remote_opts.merge!(http_client: http_client) if http_client
52+
remote_opts[:http_client] = http_client if http_client
5353

5454
begin
5555
super(remote_opts)

rb/lib/selenium/webdriver/phantomjs/bridge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def initialize(opts = {})
4747
desired_capabilities: caps
4848
}
4949

50-
remote_opts.merge!(http_client: http_client) if http_client
50+
remote_opts[:http_client] = http_client if http_client
5151

5252
super(remote_opts)
5353
end

rb/lib/selenium/webdriver/remote/bridge.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def initialize(opts = {})
9292
def browser
9393
@browser ||= (
9494
name = @capabilities.browser_name
95-
name ? name.gsub(" ", "_").to_sym : 'unknown'
95+
name ? name.tr(" ", "_").to_sym : 'unknown'
9696
)
9797
end
9898

@@ -413,7 +413,10 @@ def mouseUp
413413
def mouseMoveTo(element, x = nil, y = nil)
414414
params = {element: element}
415415

416-
params.merge! xoffset: x, yoffset: y if x && y
416+
if x && y
417+
params[:xoffset] = x
418+
params[:yoffset] = y
419+
end
417420

418421
execute :mouseMoveTo, {}, params
419422
end

rb/lib/selenium/webdriver/remote/w3c_bridge.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def initialize(opts = {})
9494
def browser
9595
@browser ||= (
9696
name = @capabilities.browser_name
97-
name ? name.gsub(" ", "_").to_sym : 'unknown'
97+
name ? name.tr(" ", "_").to_sym : 'unknown'
9898
)
9999
end
100100

@@ -418,7 +418,10 @@ def mouseUp
418418
def mouseMoveTo(element, x = nil, y = nil)
419419
params = {element: element}
420420

421-
params.merge! xoffset: x, yoffset: y if x && y
421+
if x && y
422+
params[:xoffset] = x
423+
params[:yoffset] = y
424+
end
422425

423426
execute :mouseMoveTo, {}, params
424427
end

rb/lib/selenium/webdriver/safari/bridge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def prepare_connect_file
111111
end
112112

113113
FileReaper << path
114-
path.gsub! "/", "\\" if Platform.windows?
114+
path.tr! "/", "\\" if Platform.windows?
115115

116116
path
117117
end

0 commit comments

Comments
 (0)