Skip to content

Commit c113011

Browse files
RustyNailp0deje
authored andcommitted
Update settings for rubocop.
Signed-off-by: Alex Rodionov <[email protected]>
1 parent 302453d commit c113011

File tree

19 files changed

+110
-31
lines changed

19 files changed

+110
-31
lines changed

rb/.rubocop.yml

+81-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
AllCops:
22
TargetRubyVersion: 2.0
33

4-
Style/SpaceInsideHashLiteralBraces:
4+
Layout/SpaceInsideHashLiteralBraces:
55
EnforcedStyle: no_space
66

77
Style/BracesAroundHashParameters:
@@ -46,12 +46,16 @@ Metrics/PerceivedComplexity:
4646
Max: 11
4747
Exclude:
4848
- 'lib/selenium/webdriver/chrome/legacy_bridge.rb'
49+
- 'lib/selenium/webdriver/chrome/driver.rb'
50+
- 'lib/selenium/webdriver/remote/w3c/capabilities.rb'
4951

5052
Metrics/CyclomaticComplexity:
5153
Max: 9
5254
Exclude:
5355
- 'lib/selenium/webdriver/chrome/legacy_bridge.rb'
56+
- 'lib/selenium/webdriver/chrome/driver.rb'
5457
- 'lib/selenium/webdriver/common/driver.rb'
58+
- 'lib/selenium/webdriver/remote/w3c/capabilities.rb'
5559
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
5660

5761
Metrics/ClassLength:
@@ -60,17 +64,27 @@ Metrics/ClassLength:
6064
- 'lib/selenium/webdriver/firefox/profile.rb'
6165
- 'lib/selenium/webdriver/remote/legacy_bridge.rb'
6266
- 'lib/selenium/webdriver/remote/capabilities.rb'
67+
- 'lib/selenium/webdriver/remote/oss/bridge.rb'
6368
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
69+
- 'lib/selenium/webdriver/remote/w3c/capabilities.rb'
70+
- 'lib/selenium/webdriver/remote/w3c/bridge.rb'
6471
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
6572

6673
Metrics/AbcSize:
6774
Max: 33
6875
Exclude:
76+
- 'lib/selenium/webdriver/chrome/driver.rb'
6977
- 'lib/selenium/webdriver/chrome/legacy_bridge.rb'
78+
- 'lib/selenium/webdriver/remote/w3c/capabilities.rb'
7079
- 'lib/selenium/webdriver/support/color.rb'
7180

7281
Metrics/LineLength:
7382
Max: 130
83+
Exclude:
84+
- 'lib/selenium/webdriver/remote/w3c/capabilities.rb'
85+
- 'lib/selenium/webdriver/remote/bridge.rb'
86+
- 'spec/unit/selenium/server_spec.rb'
87+
- 'lib/selenium/webdriver/ie/service.rb'
7488

7589
Metrics/ModuleLength:
7690
Exclude:
@@ -80,8 +94,74 @@ Metrics/ModuleLength:
8094
Metrics/MethodLength:
8195
Max: 33
8296
Exclude:
97+
- 'lib/selenium/webdriver/chrome/driver.rb'
8398
- 'lib/selenium/webdriver/chrome/legacy_bridge.rb'
8499

85100
Metrics/BlockLength:
86101
Exclude:
87102
- "**/*_spec.rb"
103+
104+
Metrics/ParameterLists:
105+
Exclude:
106+
- 'lib/selenium/webdriver/common/interactions/pointer_input.rb'
107+
108+
Layout/EmptyLineAfterMagicComment:
109+
Enabled: false
110+
111+
Layout/EmptyLinesAroundBlockBody:
112+
Exclude:
113+
- 'spec/**/*'
114+
115+
Layout/EmptyLinesAroundClassBody:
116+
Enabled: false
117+
118+
Layout/EmptyLinesAroundModuleBody:
119+
Enabled: false
120+
121+
Lint/UnusedBlockArgument:
122+
Enabled: false
123+
124+
Lint/UnusedMethodArgument:
125+
Enabled: false
126+
127+
Lint/UselessAssignment:
128+
Exclude:
129+
- 'spec/unit/selenium/webdriver/chrome/service_spec.rb'
130+
131+
Performance/Caller:
132+
Enabled: false
133+
134+
Style/CommentAnnotation:
135+
Enabled: false
136+
137+
Style/FormatString:
138+
Exclude:
139+
- 'lib/selenium/webdriver/atoms.rb'
140+
141+
Style/MethodMissing:
142+
Exclude:
143+
- 'lib/selenium/webdriver/support/event_firing_bridge.rb'
144+
- 'lib/selenium/webdriver/support/block_event_listener.rb'
145+
146+
Layout/MultilineMethodCallIndentation:
147+
Exclude:
148+
- 'spec/unit/selenium/webdriver/chrome/profile_spec.rb'
149+
150+
Style/MultilineMemoization:
151+
Enabled: false
152+
153+
Style/RedundantBegin:
154+
Exclude:
155+
- 'spec/integration/selenium/webdriver/driver_spec.rb'
156+
157+
Style/RedundantSelf:
158+
Enabled: false
159+
160+
Style/StringLiterals:
161+
Enabled: false
162+
163+
Style/SymbolArray:
164+
Enabled: false
165+
166+
Style/TrailingCommaInLiteral:
167+
Enabled: false

rb/lib/selenium/server.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def download(required_version)
8484
progress += segment.length
8585
segment_count += 1
8686

87-
if segment_count % 15 == 0
87+
if segment_count % 15.zero?
8888
percent = (progress.to_f / total.to_f) * 100
8989
print "#{CL_RESET}Downloading #{download_file_name}: #{percent.to_i}% (#{progress} / #{total})"
9090
segment_count = 0

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def cygwin_path(path, opts = {})
117117
end
118118

119119
def make_writable(file)
120-
File.chmod 0766, file
120+
File.chmod 0o766, file
121121
end
122122

123123
def assert_file(path)
@@ -208,7 +208,7 @@ def interfaces
208208
end # WebDriver
209209
end # Selenium
210210

211-
if __FILE__ == $PROGRAM_NAME
211+
if $PROGRAM_NAME == __FILE__
212212
p engine: Selenium::WebDriver::Platform.engine,
213213
os: Selenium::WebDriver::Platform.os,
214214
ruby_version: Selenium::WebDriver::Platform.ruby_version,

rb/lib/selenium/webdriver/common/port_prober.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def self.random
3838
port
3939
end
4040

41-
IGNORED_ERRORS = [Errno::EADDRNOTAVAIL]
41+
IGNORED_ERRORS = [Errno::EADDRNOTAVAIL].freeze
4242
IGNORED_ERRORS << Errno::EBADF if Platform.cygwin?
4343
IGNORED_ERRORS.freeze
4444

rb/lib/selenium/webdriver/common/profile_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def create_tmp_copy(directory)
4646

4747
# TODO: must be a better way..
4848
FileUtils.rm_rf tmp_directory
49-
FileUtils.mkdir_p File.dirname(tmp_directory), mode: 0700
49+
FileUtils.mkdir_p File.dirname(tmp_directory), mode: 0o700
5050
FileUtils.cp_r directory, tmp_directory
5151

5252
tmp_directory

rb/lib/selenium/webdriver/common/service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def socket_lock
155155
protected
156156

157157
def extract_service_args(driver_opts)
158-
driver_opts.key?(:args) ? driver_opts.delete(:args) : []
158+
driver_opts.key?(:args) ? driver_opts.delete(:args) : []
159159
end
160160

161161
end # Service

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ module Bridge
2424

2525
def commands(command)
2626
unsupported = %i[execute_script execute_async_script submit_element double_click
27-
mouse_down mouse_up mouse_move_to click
28-
send_keys_to_active_element get_window_handles get_current_window_handle
29-
get_window_size set_window_size get_window_position set_window_position
30-
maximize_window get_alert_text accept_alert dismiss_alert]
27+
mouse_down mouse_up mouse_move_to click
28+
send_keys_to_active_element get_window_handles get_current_window_handle
29+
get_window_size set_window_size get_window_position set_window_position
30+
maximize_window get_alert_text accept_alert dismiss_alert]
3131
if unsupported.include? command
3232
Remote::OSS::Bridge::COMMANDS[command]
3333
else

rb/lib/selenium/webdriver/firefox/extension.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def write_to(extensions_dir)
4141
ext_path = File.join extensions_dir, read_id_from_install_rdf(root_dir)
4242

4343
FileUtils.rm_rf ext_path
44-
FileUtils.mkdir_p File.dirname(ext_path), mode: 0700
44+
FileUtils.mkdir_p File.dirname(ext_path), mode: 0o700
4545
FileUtils.cp_r root_dir, ext_path
4646

4747
FileReaper.reap(root_dir) if @should_reap_root

rb/lib/selenium/webdriver/firefox/launcher.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ def connect_until_stable
9090
end
9191

9292
def fetch_profile
93-
if @profile_name
94-
@profile = Profile.from_name @profile_name
95-
else
96-
@profile = Profile.new
97-
end
93+
@profile = if @profile_name
94+
Profile.from_name @profile_name
95+
else
96+
Profile.new
97+
end
9898
end
9999

100100
def assert_profile

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def commands(command)
3434

3535
def install_addon(path, temporary)
3636
payload = {path: path}
37-
payload.merge!(temporary: temporary) unless temporary.nil?
37+
payload[:temporary] = temporary unless temporary.nil?
3838
execute :install_addon, {}, payload
3939
end
4040

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

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def request(verb, url, headers, payload, redirects = 0)
9494
retries += 1
9595
sleep 2
9696
retry
97-
9897
rescue Errno::ECONNREFUSED => ex
9998
raise ex.class, "using proxy: #{proxy.http}" if use_proxy?
10099
raise

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ def self.from_hsl(h, s, l, a)
7878
l = Float(l) / 100
7979
a = Float(a || 1)
8080

81-
if s == 0
81+
if s.zero?
8282
r = l
8383
g = r
8484
b = r
8585
else
86-
luminocity2 = (l < 0.5) ? l * (1 + s) : l + s - l * s
86+
luminocity2 = l < 0.5 ? l * (1 + s) : l + s - l * s
8787
luminocity1 = 2 * l - luminocity2
8888

8989
r = hue_to_rgb(luminocity1, luminocity2, h + 1.0 / 3.0)

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ def profile_opts
119119

120120
it 'can configure a manual proxy' do
121121
proxy = Proxy.new(
122-
http: 'foo:123',
123-
ftp: 'bar:234',
124-
ssl: 'baz:345',
125-
no_proxy: 'localhost'
122+
http: 'foo:123',
123+
ftp: 'bar:234',
124+
ssl: 'baz:345',
125+
no_proxy: 'localhost'
126126
)
127127

128128
profile.proxy = proxy

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,6 @@ def call(env)
133133
end # WebDriver
134134
end # Selenium
135135

136-
if __FILE__ == $PROGRAM_NAME
136+
if $PROGRAM_NAME == __FILE__
137137
Selenium::WebDriver::SpecSupport::RackServer.new(ARGV[0], ARGV[1]).run
138138
end

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def remote_server?
9999

100100
def remote_server_jar
101101
if ENV['DOWNLOAD_SERVER']
102-
@remote_server_jar ||= "#{root.join('rb/selenium-server-standalone').to_s}-#{Selenium::Server.latest}.jar"
102+
@remote_server_jar ||= "#{root.join('rb/selenium-server-standalone')}-#{Selenium::Server.latest}.jar"
103103
@remote_server_jar = root.join("rb/#{Selenium::Server.download(:latest)}").to_s unless File.exist? @remote_server_jar
104104
else
105105
@remote_server_jar ||= root.join('buck-out/gen/java/server/src/org/openqa/grid/selenium/selenium.jar').to_s

rb/spec/integration/selenium/webdriver/window_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ module WebDriver
106106
expect(new_rect.width).to eq(target_width)
107107
expect(new_rect.height).to eq(target_height)
108108
end
109-
end
109+
end
110110
end
111111

112112
# TODO: - Create Window Manager guard

rb/spec/unit/selenium/server_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module Selenium
7777
expect(File).to receive(:exist?).with('selenium-server-test.jar').and_return(true)
7878

7979
expect(ChildProcess).to receive(:build)
80-
.with('java', '-Dwebdriver.chrome.driver=/bin/chromedriver','-jar', 'selenium-server-test.jar', '-port', '4444', 'foo', 'bar')
80+
.with('java', '-Dwebdriver.chrome.driver=/bin/chromedriver', '-jar', 'selenium-server-test.jar', '-port', '4444', 'foo', 'bar')
8181
.and_return(mock_process)
8282

8383
server = Selenium::Server.new('selenium-server-test.jar', background: true)

rb/spec/unit/selenium/webdriver/chrome/service_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module Chrome
8282
end
8383

8484
it 'deprecates `service_log_path`' do
85-
message = /\[DEPRECATION\] `:service_log_path` is deprecated. Use `driver_opts: {log_path: \/path\/to\/log}`/
85+
message = %r{\[DEPRECATION\] `:service_log_path` is deprecated. Use `driver_opts: {log_path: \/path\/to\/log}`}
8686

8787
expect(WebDriver.logger).to receive(:deprecate).with(':service_log_path', "driver_opts: {log_path: '/path/to/log'}")
8888
@driver = Driver.new(http_client: http, service_log_path: "/path/to/log")

rb/spec/unit/selenium/webdriver/remote/bridge_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module Remote
7272

7373
it 'supports responses with "value" capabilities' do
7474
allow(http).to receive(:request)
75-
.and_return({'status' => 200, 'sessionId' => '', 'value' => {'browserName' => 'firefox'}})
75+
.and_return('status' => 200, 'sessionId' => '', 'value' => {'browserName' => 'firefox'})
7676

7777
bridge = Bridge.handshake(http_client: http, desired_capabilities: Capabilities.new)
7878
expect(bridge.capabilities[:browser_name]).to eq('firefox')

0 commit comments

Comments
 (0)