Showing 48 of 75 total issues

File html_elements.rb has 1578 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Watir
  class HTMLElement < Element
    attribute(String, :title, :title)
    attribute(String, :lang, :lang)
    attribute("Boolean", :translate?, :translate)
Severity: Major
Found in lib/watir/elements/html_elements.rb - About 4 days to fix

    Class Element has 63 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Element
        extend AttributeHelper
    
        include Exception
        include Container
    Severity: Major
    Found in lib/watir/elements/element.rb - About 1 day to fix

      Method process_browser_options has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_browser_options
            browser_options = @options.delete(:options) || {}
      
            case @selenium_browser
            when :chrome
      Severity: Minor
      Found in lib/watir/capabilities.rb - About 6 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      File element.rb has 407 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Watir
        #
        # Base class for HTML elements.
        #
      
      
      Severity: Minor
      Found in lib/watir/elements/element.rb - About 5 hrs to fix

        File svg_elements.rb has 393 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Watir
          class SVGElement < HTMLElement
            attribute(String, :classname, :className)
            attribute(String, :ownersvgelement, :ownerSVGElement)
            attribute(String, :viewportelement, :viewportElement)
        Severity: Minor
        Found in lib/watir/elements/svg_elements.rb - About 5 hrs to fix

          Method element_call has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

              def element_call(precondition = nil, &block)
                caller = caller_locations(1, 1)[0].label
                already_locked = Wait.timer.locked?
                Wait.timer = Wait::Timer.new(timeout: Watir.default_timeout) unless already_locked
          
          
          Severity: Minor
          Found in lib/watir/elements/element.rb - About 4 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method find_options has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              def find_options(how, str_or_rx)
                wait_while do
                  case str_or_rx
                  when String, Numeric, Regexp
                    @found = how == :value ? options(value: str_or_rx) : []
          Severity: Minor
          Found in lib/watir/elements/select.rb - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Class Browser has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Browser
              include Container
              include HasWindow
              include Waitable
              include Navigation
          Severity: Minor
          Found in lib/watir/browser.rb - About 2 hrs to fix

            Class Window has 22 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Window
                include EventuallyPresent
                include Waitable
                include Exception
            
            
            Severity: Minor
            Found in lib/watir/window.rb - About 2 hrs to fix

              Method process_browser_options has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def process_browser_options
                    browser_options = @options.delete(:options) || {}
              
                    case @selenium_browser
                    when :chrome
              Severity: Major
              Found in lib/watir/capabilities.rb - About 2 hrs to fix

                Class XPath has 21 methods (exceeds 20 allowed). Consider refactoring.
                Open

                        class XPath
                          include Exception
                          include XpathSupport
                
                          CAN_NOT_BUILD = %i[visible visible_text visible_label_element].freeze
                Severity: Minor
                Found in lib/watir/locators/element/selector_builder/xpath.rb - About 2 hrs to fix

                  Method extract_strings has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def extract_strings(expression, strings)
                              expression.each do |exp|
                                if optional?(exp)
                                  strings.push(+'')
                                  next
                  Severity: Minor
                  Found in lib/watir/locators/element/selector_builder/regexp_disassembler.rb - About 2 hrs to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method element_call has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def element_call(precondition = nil, &block)
                        caller = caller_locations(1, 1)[0].label
                        already_locked = Wait.timer.locked?
                        Wait.timer = Wait::Timer.new(timeout: Watir.default_timeout) unless already_locked
                  
                  
                  Severity: Minor
                  Found in lib/watir/elements/element.rb - About 1 hr to fix

                    Method normalize_selector has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def normalize_selector
                              raise LocatorException, "Can not locate element with #{wd_locators}" if wd_locators.size > 1
                    
                              @selector[:scope] = @query_scope.selector_builder.built if merge_scope?
                    
                    
                    Severity: Minor
                    Found in lib/watir/locators/element/selector_builder.rb - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method elements_match? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def elements_match?(element, values_to_match)
                              case fetch_value(element, :tag_name)
                              when 'input'
                                %i[text label visible_text].each do |key|
                                  next unless values_to_match.key?(key)
                    Severity: Minor
                    Found in lib/watir/locators/text_field/matcher.rb - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method jar has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def jar
                          if ENV['LOCAL_SELENIUM']
                            local = File.expand_path('../selenium/buck-out/gen/java/server/src/org/openqa/grid/selenium/selenium.jar')
                          end
                    
                    
                    Severity: Minor
                    Found in lib/watirspec/remote_server.rb - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method matching_elements has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def matching_elements
                              return locate_element(*@built.to_a.flatten) if @built.size == 1 && @filter == :first
                    
                              # TODO: Wrap this to continue trying until default timeout
                              retries = 0
                    Severity: Minor
                    Found in lib/watir/locators/element/locator.rb - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method select has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def select(str_or_rx)
                          %i[value label].each do |key|
                            radio = radio(key => str_or_rx)
                            next unless radio.exist?
                    
                    
                    Severity: Minor
                    Found in lib/watir/radio_set.rb - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method matching_option? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def matching_option?(how, what)
                          selected_options.each do |opt|
                            value = opt.send(how)
                            next unless what.is_a?(String) ? value == what : value =~ what
                            return true if opt.enabled?
                    Severity: Minor
                    Found in lib/watir/elements/select.rb - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method normalize_locator has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def normalize_locator(how, what)
                              case how
                              when 'text'
                                Watir.logger.deprecate "String 'text' as a locator", 'Symbol :text', ids: [:text_string]
                                [:text, what]
                    Severity: Minor
                    Found in lib/watir/locators/element/selector_builder.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language