Skip to content

Commit

Permalink
rb - update the literals
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jun 16, 2016
1 parent ccc5674 commit 9551fe6
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 86 deletions.
7 changes: 6 additions & 1 deletion rb/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent

Lint/AssignmentInCondition:
Enabled: false
Enabled: false

Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%i': '[]'
'%w': '[]'
69 changes: 5 additions & 64 deletions rb/.rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-06-08 19:18:26 -0700 using RuboCop version 0.37.2.
# on 2016-06-09 12:14:10 -0700 using RuboCop version 0.37.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -60,7 +60,7 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Max: 16

# Offense count: 716
# Offense count: 713
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Expand All @@ -71,10 +71,10 @@ Metrics/LineLength:
Metrics/MethodLength:
Max: 37

# Offense count: 4
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 223
Max: 222

# Offense count: 15
Metrics/PerceivedComplexity:
Expand Down Expand Up @@ -103,14 +103,6 @@ Style/AsciiComments:
Exclude:
- 'lib/selenium/webdriver/common/w3c_error.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: percent_q, bare_percent
Style/BarePercentLiterals:
Exclude:
- 'spec/integration/selenium/webdriver/firefox/profile_spec.rb'

# Offense count: 5
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Expand Down Expand Up @@ -257,33 +249,6 @@ Style/ParallelAssignment:
- 'spec/unit/selenium/webdriver/remote/capabilities_spec.rb'
- 'spec/unit/selenium/webdriver/support/event_firing_spec.rb'

# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'lib/selenium/webdriver/chrome/bridge.rb'
- 'lib/selenium/webdriver/common/element.rb'
- 'lib/selenium/webdriver/common/platform.rb'
- 'lib/selenium/webdriver/common/zipper.rb'
- 'lib/selenium/webdriver/firefox/profile.rb'
- 'lib/selenium/webdriver/support/select.rb'
- 'spec/integration/selenium/webdriver/driver_spec.rb'
- 'spec/integration/selenium/webdriver/spec_support/helpers.rb'
- 'spec/integration/selenium/webdriver/spec_support/rack_server.rb'
- 'spec/unit/selenium/webdriver/chrome/bridge_spec.rb'
- 'spec/unit/selenium/webdriver/phantomjs/bridge_spec.rb'
- 'spec/unit/selenium/webdriver/remote/http/default_spec.rb'
- 'spec/unit/selenium/webdriver/support/select_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: lower_case_q, upper_case_q
Style/PercentQLiterals:
Exclude:
- 'spec/integration/selenium/webdriver/firefox/profile_spec.rb'

# Offense count: 28
# Cop supports --auto-correct.
Style/PerlBackrefs:
Expand Down Expand Up @@ -314,16 +279,6 @@ Style/RedundantSelf:
Exclude:
- 'lib/selenium/webdriver/common/html5/shared_web_storage.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- 'lib/selenium/webdriver/remote/bridge.rb'
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
- 'spec/integration/selenium/webdriver/element_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/RescueModifier:
Expand Down Expand Up @@ -354,7 +309,7 @@ Style/SingleLineMethods:
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names

# Offense count: 1416
# Offense count: 1410
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Expand Down Expand Up @@ -395,12 +350,6 @@ Style/TrivialAccessors:
- 'lib/selenium/webdriver/remote/capabilities.rb'
- 'lib/selenium/webdriver/remote/w3c_capabilities.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/UnneededPercentQ:
Exclude:
- 'spec/integration/selenium/webdriver/firefox/profile_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Expand All @@ -409,14 +358,6 @@ Style/WhileUntilModifier:
- 'lib/selenium/webdriver/common/socket_lock.rb'
- 'lib/selenium/webdriver/safari/server.rb'

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
MinSize: 3

# Offense count: 1
Style/ZeroLengthPredicate:
Exclude:
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def null_device
end

def wrap_in_quotes_if_necessary(str)
windows? && !cygwin? ? %{"#{str}"} : str
windows? && !cygwin? ? %("#{str}") : str
end

def cygwin_path(path, opts = {})
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/remote/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def initialize(opts = {})
end

uri = url.kind_of?(URI) ? url : URI.parse(url)
uri.path += "/" unless uri.path =~ /\/$/
uri.path += "/" unless uri.path =~ %r{\/$}

http_client.server_url = uri

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/remote/w3c_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def initialize(opts = {})
end

uri = url.kind_of?(URI) ? url : URI.parse(url)
uri.path += "/" unless uri.path =~ /\/$/
uri.path += "/" unless uri.path =~ %r{\/$}

http_client.server_url = uri

Expand Down
6 changes: 3 additions & 3 deletions rb/lib/selenium/webdriver/support/select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ def find_by_value(value)
module Escaper
def self.escape(str)
if str.include?('"') && str.include?("'")
parts = str.split('"', -1).map { |part| %{"#{part}"} }
parts = str.split('"', -1).map { |part| %("#{part}") }

quoted = parts.join(%{, '"', }).
quoted = parts.join(%(, '"', )).
gsub(/^"", |, ""$/, '')

"concat(#{quoted})"
Expand All @@ -311,7 +311,7 @@ def self.escape(str)
"'#{str}'"
else
# otherwise return the quoted string
%{"#{str}"}
%("#{str}")
end
end
end # Escaper
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

it "should get the page source" do
driver.navigate.to url_for("xhtmlTest.html")
expect(driver.page_source).to match(%r[<title>XHTML Test Page</title>]i)
expect(driver.page_source).to match(%r{<title>XHTML Test Page</title>}i)
end

it "should refresh the page" do
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
driver.navigate.to url_for("click_tests/overlapping_elements.html")
expect { driver.find_element(:id, "contents").click }
.to raise_error(Selenium::WebDriver::Error::UnknownError,
/Element is not clickable at point \(\d+, \d+\)\. Other element would receive the click: <div id="over"><\/div>/)
%r{Element is not clickable at point \(\d+, \d+\)\. Other element would receive the click: <div id="over"><\/div>})
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def read_generated_prefs(from = nil)
profile["browser.startup.page"] = "http://example.com"

string = read_generated_prefs
expect(string).to include(%Q{user_pref("browser.startup.page", "http://example.com")})
expect(string).to include(%{user_pref("browser.startup.page", "http://example.com")})
end

it "should raise an error if the value given is not a string, number or boolean" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def fix_windows_path(path)
return path unless WebDriver::Platform.os == :windows

if GlobalTestEnv.browser == :ie
path = path[%r[file://(.*)], 1]
path = path[%r{file://(.*)}, 1]
path.tr!("/", '\\')

"file://#{path}"
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/integration/selenium/webdriver/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ module Selenium::WebDriver::DriverExtensions
storage['foo3'] = 'bar3'

expect(storage.to_a).to include(
['foo1', 'bar1'],
['foo2', 'bar2'],
['foo3', 'bar3']
%w[foo1 bar1],
%w[foo2 bar2],
%w[foo3 bar3]
)
end

Expand Down
2 changes: 1 addition & 1 deletion rb/spec/unit/selenium/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
server = Selenium::Server.new("selenium-server-test.jar", background: true)
allow(server).to receive(:socket).and_return(mock_poller)

server << ["foo", "bar"]
server << %w[foo bar]

server.start
end
Expand Down
6 changes: 3 additions & 3 deletions rb/spec/unit/selenium/webdriver/remote/http/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module Http
expect { client.send :http }.to raise_error(Error::WebDriverError)
end

["http_proxy", "HTTP_PROXY"].each do |proxy_var|
%w[http_proxy HTTP_PROXY].each do |proxy_var|
it "honors the #{proxy_var} environment varable" do
with_env(proxy_var => "http://proxy.org:8080") do
http = client.send :http
Expand All @@ -79,7 +79,7 @@ module Http
end
end

["no_proxy", "NO_PROXY"].each do |no_proxy_var|
%w[no_proxy NO_PROXY].each do |no_proxy_var|
it "honors the #{no_proxy_var} environment variable when matching" do
with_env("HTTP_PROXY" => "proxy.org:8080", no_proxy_var => "example.com") do
http = client.send :http
Expand Down Expand Up @@ -130,7 +130,7 @@ module Http

expect do
client.call :post, 'http://example.com/foo/bar', {}
end.to raise_error(Errno::ECONNREFUSED, %r[using proxy: http://localhost:1234])
end.to raise_error(Errno::ECONNREFUSED, %r{using proxy: http://localhost:1234})
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions rb/spec/unit/selenium/webdriver/support/select_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,19 @@ module Support
end

it 'double quotes a string that contains a single quote' do
expect(Select::Escaper.escape("f'oo")).to eq(%{"f'oo"})
expect(Select::Escaper.escape("f'oo")).to eq(%("f'oo"))
end

it 'single quotes a string that contains a double quote' do
expect(Select::Escaper.escape('f"oo')).to eq(%{'f"oo'})
expect(Select::Escaper.escape('f"oo')).to eq(%('f"oo'))
end

it 'provides concatenated strings when string to escape contains both single and double quotes' do
expect(Select::Escaper.escape(%{f"o'o})).to eq(%{concat("f", '"', "o'o")})
expect(Select::Escaper.escape(%(f"o'o))).to eq(%{concat("f", '"', "o'o")})
end

it 'provides concatenated strings when string ends with quote' do
expect(Select::Escaper.escape(%{'"})).to eq(%{concat("'", '"')})
expect(Select::Escaper.escape(%('"))).to eq(%{concat("'", '"')})
end
end # Select::Escaper
end # Support
Expand Down

0 comments on commit 9551fe6

Please sign in to comment.