Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions rb/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ Metrics/AbcSize:
Max: 30
Exclude:
- 'lib/selenium/webdriver/common/driver_finder.rb'
- 'lib/selenium/webdriver/common/options.rb'
- 'lib/selenium/webdriver/remote/capabilities.rb'
- 'lib/selenium/webdriver/remote/http/curb.rb'
- 'lib/selenium/webdriver/support/color.rb'
- '../rake_tasks/**/*'
Expand All @@ -36,35 +34,29 @@ Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
- 'selenium-*.gemspec'
- 'Steepfile'
- '../rake_tasks/**/*'
- '../Rakefile'

Metrics/ClassLength:
CountComments: false
Max: 160
Exclude:
- 'lib/selenium/webdriver/common/driver.rb'
- 'lib/selenium/webdriver/remote/bridge.rb'
- 'lib/selenium/webdriver/remote/capabilities.rb'
- 'spec/integration/selenium/webdriver/spec_support/test_environment.rb'
- 'spec/**/*.rb'

Metrics/CyclomaticComplexity:
Max: 9
Exclude:
- 'lib/selenium/webdriver/support/color.rb'
- 'lib/selenium/webdriver/common/logger.rb'
- '../rake_tasks/**/*'

Metrics/MethodLength:
CountComments: false
Max: 22
Exclude:
- 'lib/selenium/server.rb'
- 'lib/selenium/webdriver/common/options.rb'
- 'lib/selenium/webdriver/common/driver.rb'
- 'lib/selenium/webdriver/common/driver_finder.rb'
- 'lib/selenium/webdriver/remote/http/default.rb'
- '../rake_tasks/**/*'

Metrics/ModuleLength:
Expand All @@ -77,9 +69,6 @@ Metrics/ModuleLength:
Metrics/PerceivedComplexity:
Max: 9
Exclude:
- 'lib/selenium/webdriver/common/options.rb'
- 'lib/selenium/webdriver/common/local_driver.rb'
- 'lib/selenium/webdriver/common/logger.rb'
- '../rake_tasks/**/*'

Naming/BlockForwarding:
Expand Down Expand Up @@ -147,6 +136,10 @@ Style/Dir:
Style/Documentation:
Enabled: false

Style/MixinUsage:
Exclude:
- 'spec/integration/selenium/webdriver/spec_helper.rb'

Style/HashEachMethods:
Enabled: true

Expand Down
2 changes: 0 additions & 2 deletions rb/Steepfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

# rubocop:disable Metrics/BlockLength -- Disable due to the steep configuration not matching rubocop expectations
target :lib do
signature 'sig', '.gem_rbs_collection/rubyzip' # Signature directory
check 'lib' # Directory name
Expand Down Expand Up @@ -88,4 +87,3 @@ target :lib do
'zlib'
)
end
# rubocop:enable Metrics/BlockLength
6 changes: 5 additions & 1 deletion rb/lib/selenium/webdriver/support/block_event_listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ def initialize(callback)
@callback = callback
end

def method_missing(meth, *) # rubocop:disable Style/MissingRespondToMissing
def method_missing(meth, *)
@callback.call(meth, *)
end

def respond_to_missing?(_meth, _include_private = false)
true
end
end # BlockEventListener
end # Support
end # WebDriver
Expand Down
28 changes: 14 additions & 14 deletions rb/lib/selenium/webdriver/support/color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,26 @@ def self.from_string(str)
end
end

def self.from_hsl(h, s, l, a) # rubocop:disable Naming/MethodParameterName
h = Float(h) / 360
s = Float(s) / 100
l = Float(l) / 100
a = Float(a || 1)

if s.zero?
r = l
def self.from_hsl(hue, sat, light, alpha)
hue = Float(hue) / 360
sat = Float(sat) / 100
light = Float(light) / 100
alpha = Float(alpha || 1)

if sat.zero?
r = light
g = r
b = r
else
luminocity2 = l < 0.5 ? l * (s + 1) : l + s - (l * s)
luminocity1 = (l * 2) - luminocity2
luminocity2 = light < 0.5 ? light * (sat + 1) : light + sat - (light * sat)
luminocity1 = (light * 2) - luminocity2

r = hue_to_rgb(luminocity1, luminocity2, h + (1.0 / 3.0))
g = hue_to_rgb(luminocity1, luminocity2, h)
b = hue_to_rgb(luminocity1, luminocity2, h - (1.0 / 3.0))
r = hue_to_rgb(luminocity1, luminocity2, hue + (1.0 / 3.0))
g = hue_to_rgb(luminocity1, luminocity2, hue)
b = hue_to_rgb(luminocity1, luminocity2, hue - (1.0 / 3.0))
end

new (r * 255).round, (g * 255).round, (b * 255).round, a
new (r * 255).round, (g * 255).round, (b * 255).round, alpha
end

def self.hue_to_rgb(lum1, lum2, hue)
Expand Down
6 changes: 5 additions & 1 deletion rb/lib/selenium/webdriver/support/event_firing_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ def dispatch(name, *)
returned
end

def method_missing(meth, ...) # rubocop:disable Style/MissingRespondToMissing
def method_missing(meth, ...)
@delegate.__send__(meth, ...)
end

def respond_to_missing?(meth, include_private = false)
@delegate.respond_to?(meth, include_private) || super
end
end # EventFiringBridge
end # Support
end # WebDriver
Expand Down
2 changes: 1 addition & 1 deletion rb/sig/lib/selenium/webdriver/support/color.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module Selenium

def self.from_string: (String str) -> untyped

def self.from_hsl: (untyped h, untyped s, untyped l, untyped a) -> untyped
def self.from_hsl: (untyped hue, untyped sat, untyped light, untyped alpha) -> untyped

def self.hue_to_rgb: (untyped lum1, untyped lum2, untyped hue) -> untyped

Expand Down
8 changes: 1 addition & 7 deletions rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,7 @@ module WebDriver
expect(driver.find_element(name: 'x').attribute('value')).to eq('name')
end

it 'finds by class name' do # rubocop:disable RSpec/RepeatedExample
driver.navigate.to url_for('xhtmlTest.html')
expect(driver.find_element(class: 'header').text).to eq('XHTML Might Be The Future')
end

# TODO: Rewrite this test so it's not a duplicate of above or remove
it 'finds elements with a hash selector' do # rubocop:disable RSpec/RepeatedExample
it 'finds by class name' do
driver.navigate.to url_for('xhtmlTest.html')
expect(driver.find_element(class: 'header').text).to eq('XHTML Might Be The Future')
end
Expand Down
2 changes: 1 addition & 1 deletion rb/spec/integration/selenium/webdriver/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
require_relative 'spec_support'
require_relative '../../../rspec_matchers'

include Selenium # rubocop:disable Style/MixinUsage
include Selenium

GlobalTestEnv = WebDriver::SpecSupport::TestEnvironment.new

Expand Down
Loading