Updated

lib/automation_object/blue_print/hash_adapter/helpers / element_helper.rb

D
60 lines of codes
6 methods
5.7 complexity/method
14 loc/method
34 complexity
65 duplications
# frozen_string_literal: true module AutomationObject module BluePrint module HashAdapter # Helper module for Element composite classes module ElementHelper # @return [String, nil] text input for automatic screen/modal change if needed def default_input hash[:default_input] end # @return [Array<Symbol, String>, nil] params as an array for driver find_element args def selector_params
  1. Identical code found in 2 nodes Locations: 0 1
if hash[:xpath].is_a?(String)
  1. AutomationObject::BluePrint::HashAdapter::ElementHelper#selector_params calls 'hash[:xpath]' 2 times Locations: 0 1
[:xpath, hash[:xpath]]
  1. AutomationObject::BluePrint::HashAdapter::ElementHelper#selector_params calls 'hash[:xpath]' 2 times Locations: 0 1
elsif hash[:css].is_a?(String)
  1. AutomationObject::BluePrint::HashAdapter::ElementHelper#selector_params calls 'hash[:css]' 2 times Locations: 0 1
[:css, hash[:css]]
  1. AutomationObject::BluePrint::HashAdapter::ElementHelper#selector_params calls 'hash[:css]' 2 times Locations: 0 1
end end # @return [Symbol, nil] element name of iframe element is in or nil if not def in_iframe case hash[:in_iframe]
  1. AutomationObject::BluePrint::HashAdapter::ElementHelper#in_iframe calls 'hash[:in_iframe]' 2 times Locations: 0 1
when Symbol, String hash[:in_iframe].to_sym
  1. AutomationObject::BluePrint::HashAdapter::ElementHelper#in_iframe calls 'hash[:in_iframe]' 2 times Locations: 0 1
end end # @return [Boolean] whether or not element is in iframe def in_iframe? in_iframe ? true : false end def method_hook?(name) method_hooks.key?(name) end # @return [Hash<Hook>] hash of Hook that are defined under the element def method_hooks
  1. Identical code found in 2 nodes Locations: 0 1
  2. AutomationObject::BluePrint::HashAdapter::ElementHelper#method_hooks has approx 7 statements
return @method_hooks if defined? @method_hooks children = {} hash.each do |key, value| # Skip possible keys that elements can have # Otherwise should be a method hook next if %i[load custom_methods in_iframe css xpath define_elements_by custom_range].include?(key) children[key] = value end @method_hooks = create_hash_children(children, interface: Hook, location: location + '[hook]') @method_hooks end end end end end