Skip to content

Commit

Permalink
rb - update conditional formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jun 16, 2016
1 parent 26ce4eb commit fa682a1
Show file tree
Hide file tree
Showing 38 changed files with 119 additions and 240 deletions.
3 changes: 3 additions & 0 deletions rb/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ Style/SpaceInsideHashLiteralBraces:

Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent

Lint/AssignmentInCondition:
Enabled: false
117 changes: 8 additions & 109 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 15:50:57 -0700 using RuboCop version 0.37.2.
# on 2016-06-08 18:56:38 -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 All @@ -11,34 +11,12 @@ Lint/AmbiguousRegexpLiteral:
Exclude:
- 'spec/integration/selenium/webdriver/firefox/marionette_spec.rb'

# Offense count: 12
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'lib/selenium/webdriver/common/bridge_helper.rb'
- 'lib/selenium/webdriver/common/options.rb'
- 'lib/selenium/webdriver/common/search_context.rb'
- 'lib/selenium/webdriver/firefox/binary.rb'
- 'lib/selenium/webdriver/firefox/profiles_ini.rb'
- 'lib/selenium/webdriver/remote/bridge.rb'
- 'lib/selenium/webdriver/remote/http/default.rb'
- 'lib/selenium/webdriver/remote/http/persistent.rb'
- 'lib/selenium/webdriver/remote/response.rb'
- 'lib/selenium/webdriver/safari/server.rb'

# Offense count: 2
# Cop supports --auto-correct.
Lint/DeprecatedClassMethods:
Exclude:
- 'lib/selenium/server.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
# SupportedStyles: keyword, variable, start_of_line
Lint/EndAlignment:
Enabled: false

# Offense count: 10
Lint/HandleExceptions:
Exclude:
Expand All @@ -51,11 +29,6 @@ Lint/HandleExceptions:
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'

# Offense count: 1
Lint/IneffectiveAccessModifier:
Exclude:
- 'lib/selenium/server.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks.
Expand Down Expand Up @@ -95,19 +68,19 @@ Metrics/AbcSize:
# Offense count: 13
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 428
Max: 427

# Offense count: 24
Metrics/CyclomaticComplexity:
Max: 17
Max: 16

# Offense count: 721
# Offense count: 717
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 318

# Offense count: 62
# Offense count: 61
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 37
Expand All @@ -119,7 +92,7 @@ Metrics/ModuleLength:

# Offense count: 15
Metrics/PerceivedComplexity:
Max: 17
Max: 16

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

# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'lib/selenium/webdriver/chrome.rb'
- 'lib/selenium/webdriver/common/bridge_helper.rb'
- 'lib/selenium/webdriver/common/driver_extensions/uploads_files.rb'
- 'lib/selenium/webdriver/common/keys.rb'
- 'lib/selenium/webdriver/edge.rb'
- 'lib/selenium/webdriver/firefox.rb'
- 'lib/selenium/webdriver/ie.rb'
- 'lib/selenium/webdriver/phantomjs.rb'
- 'lib/selenium/webdriver/remote/bridge.rb'
- 'lib/selenium/webdriver/remote/http/common.rb'
- 'lib/selenium/webdriver/remote/response.rb'
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
- 'lib/selenium/webdriver/support/select.rb'

# Offense count: 3
Style/AsciiComments:
Exclude:
Expand All @@ -229,13 +182,6 @@ Style/BarePercentLiterals:
Style/BlockDelimiters:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth.
# SupportedStyles: case, end
Style/CaseIndentation:
Enabled: false

# Offense count: 5
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Expand Down Expand Up @@ -278,17 +224,6 @@ Style/CommentIndentation:
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
- 'spec/integration/selenium/webdriver/target_locator_spec.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: SingleLineConditionsOnly.
Style/ConditionalAssignment:
Exclude:
- 'lib/selenium/webdriver/common/*'
- 'lib/selenium/webdriver/firefox/*'
- 'lib/selenium/webdriver/remote/*'
- 'lib/selenium/webdriver/support/event_firing_bridge.rb'
- 'spec/integration/selenium/webdriver/spec_support/rack_server.rb'

# Offense count: 1
Style/ConstantName:
Exclude:
Expand Down Expand Up @@ -318,19 +253,6 @@ Style/Documentation:
Style/DotPosition:
Enabled: false

# Offense count: 12
Style/DoubleNegation:
Exclude:
- 'lib/selenium/webdriver/chrome/bridge.rb'
- 'lib/selenium/webdriver/common/file_reaper.rb'
- 'lib/selenium/webdriver/common/platform.rb'
- 'lib/selenium/webdriver/common/socket_lock.rb'
- 'lib/selenium/webdriver/remote/http/curb.rb'
- 'lib/selenium/webdriver/safari/options.rb'
- 'spec/integration/selenium/webdriver/spec_helper.rb'
- 'spec/integration/selenium/webdriver/spec_support/guards.rb'
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'

# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: AllowAdjacentOneLineDefs.
Expand Down Expand Up @@ -416,21 +338,6 @@ Style/FormatString:
- 'lib/selenium/webdriver/safari/server.rb'
- 'lib/selenium/webdriver/support/color.rb'

# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'lib/selenium/server.rb'
- 'lib/selenium/webdriver/common/driver.rb'
- 'lib/selenium/webdriver/edge/legacy_support.rb'
- 'lib/selenium/webdriver/remote/bridge.rb'
- 'lib/selenium/webdriver/remote/response.rb'
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
- 'selenium-webdriver.gemspec'
- 'spec/integration/selenium/webdriver/spec_helper.rb'
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
Expand All @@ -446,7 +353,7 @@ Style/IndentationConsistency:
Exclude:
- 'spec/unit/selenium/webdriver/remote/http/default_spec.rb'

# Offense count: 4
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: Width.
Style/IndentationWidth:
Expand Down Expand Up @@ -508,14 +415,6 @@ Style/MultilineOperationIndentation:
Style/MutableConstant:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
Exclude:
- 'lib/selenium/webdriver/firefox/profile.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/Not:
Expand Down Expand Up @@ -695,7 +594,7 @@ Style/SpaceInsideStringInterpolation:
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names

# Offense count: 1418
# Offense count: 1417
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Expand Down
4 changes: 1 addition & 3 deletions rb/lib/selenium/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def download(required_version)
required_version = latest if required_version == :latest
download_file_name = "selenium-server-standalone-#{required_version}.jar"

if File.exists? download_file_name
return download_file_name
end
return download_file_name if File.exists? download_file_name

begin
open(download_file_name, "wb") do |destination|
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.driver_path=(path)
def self.driver_path
@driver_path ||= begin
path = Platform.find_binary("chromedriver")
path or raise Error::WebDriverError, MISSING_TEXT
raise Error::WebDriverError, MISSING_TEXT unless path
Platform.assert_executable path

path
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/chrome/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def create_capabilities(opts)
chrome_options['binary'] = Chrome.path if Chrome.path
chrome_options['nativeEvents'] = true if native_events
chrome_options['verbose'] = true if verbose
chrome_options['detach'] = detach.nil? || !!detach
chrome_options['detach'] = detach != false
chrome_options['noWebsiteTestingDefaults'] = true if no_website_testing_defaults
chrome_options['prefs'] = prefs if prefs

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/chrome/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def start_process
server_command = [@executable_path, "--port=#{@port}", *@extra_args]
@process = ChildProcess.build(*server_command)

@process.io.inherit! if $DEBUG == true
@process.io.inherit! if $DEBUG
@process.start
end

Expand Down
10 changes: 5 additions & 5 deletions rb/lib/selenium/webdriver/common/action_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ def double_click(element = nil)
#

def move_to(element, right_by = nil, down_by = nil)
if right_by && down_by
@actions << [:mouse, :move_to, [element, Integer(right_by), Integer(down_by)]]
else
@actions << [:mouse, :move_to, [element]]
end
@actions << if right_by && down_by
[:mouse, :move_to, [element, Integer(right_by), Integer(down_by)]]
else
[:mouse, :move_to, [element]]
end

self
end
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/bridge_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def unwrap_script_result(arg)
end

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

def parse_cookie_string(str)
Expand Down
4 changes: 1 addition & 3 deletions rb/lib/selenium/webdriver/common/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ def execute_async_script(script, *args)
#

def [](sel)
if sel.kind_of?(String) || sel.kind_of?(Symbol)
sel = {id: sel}
end
sel = {id: sel} if sel.kind_of?(String) || sel.kind_of?(Symbol)

find_element sel
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module UploadsFiles
#

def file_detector=(detector)
unless detector.nil? or detector.respond_to? :call
unless detector.nil? || detector.respond_to?(:call)
raise ArgumentError, "detector must respond to #call"
end

Expand Down
3 changes: 1 addition & 2 deletions rb/lib/selenium/webdriver/common/file_reaper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def reap=(bool)
end

def reap?
@reap = true unless defined?(@reap)
!!@reap
@reap = defined?(@reap) ? @reap : true
end

def tmp_files
Expand Down
3 changes: 2 additions & 1 deletion rb/lib/selenium/webdriver/common/keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ module Keys
#

def self.[](key)
KEYS[key] or raise Error::UnsupportedOperationError, "no such key #{key.inspect}"
return KEYS[key] if KEYS[key]
raise Error::UnsupportedOperationError, "no such key #{key.inspect}"
end

#
Expand Down
3 changes: 2 additions & 1 deletion rb/lib/selenium/webdriver/common/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def linux?
end

def cygwin?
!!(RUBY_PLATFORM =~ /cygwin/)
RUBY_PLATFORM =~ /cygwin/
!Regexp.last_match.nil?
end

def null_device
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/socket_lock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def can_lock?
end

def did_lock?
!!@server
!@server.nil?
end

end # SocketLock
Expand Down
10 changes: 5 additions & 5 deletions rb/lib/selenium/webdriver/common/wait.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def until(&blk)
end


if @message
msg = @message.dup
else
msg = "timed out after #{@timeout} seconds"
end
msg = if @message
@message.dup
else
"timed out after #{@timeout} seconds"
end

msg << " (#{last_error.message})" if last_error

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/edge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def self.driver_path=(path)
def self.driver_path
@driver_path ||= begin
path = Platform.find_binary("MicrosoftWebDriver")
path or raise Error::WebDriverError, MISSING_TEXT
raise Error::WebDriverError, MISSING_TEXT unless path
Platform.assert_executable path

path
Expand Down
4 changes: 1 addition & 3 deletions rb/lib/selenium/webdriver/edge/legacy_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def mouseUp
def mouseMoveTo(element, x = nil, y = nil)
params = {element: element}

if x && y
params.merge! xoffset: x, yoffset: y
end
params.merge! xoffset: x, yoffset: y if x && y

execute :mouseMoveTo, {}, params
end
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/edge/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def start_process
server_command = [@executable_path, "--port=#{@port}", *@extra_args]
@process = ChildProcess.build(*server_command)

@process.io.inherit! if $DEBUG == true
@process.io.inherit! if $DEBUG
@process.start
end

Expand Down
Loading

0 comments on commit fa682a1

Please sign in to comment.