Showing 76 of 76 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 425 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 6 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 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def element_call(precondition = nil, &block)
                caller = caller_locations(1, 1)[0].label
                already_locked = browser.timer.locked?
                browser.timer = Wait::Timer.new(timeout: Watir.default_timeout) unless already_locked
          
          
          Severity: Minor
          Found in lib/watir/elements/element.rb - About 3 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 25 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 XPath has 23 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

              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

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      def wait_while(depr_timeout = nil, depr_message = nil, timeout: nil, message: nil, interval: nil, **opt, &blk)
                        if depr_message || depr_timeout
                          Watir.logger.deprecate 'Using arguments for #wait_while', 'keywords', ids: [:timeout_arguments]
                          timeout = depr_timeout
                          message = depr_message
                  Severity: Major
                  Found in lib/watir/wait.rb and 1 other location - About 1 hr to fix
                  lib/watir/wait.rb on lines 114..127

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 59.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      def wait_until(depr_timeout = nil, depr_message = nil, timeout: nil, message: nil, interval: nil, **opt, &blk)
                        if depr_message || depr_timeout
                          Watir.logger.deprecate 'Using arguments for #wait_until', 'keywords', ids: [:timeout_arguments]
                          timeout = depr_timeout
                          message = depr_message
                  Severity: Major
                  Found in lib/watir/wait.rb and 1 other location - About 1 hr to fix
                  lib/watir/wait.rb on lines 145..158

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 59.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                      def xpath_adjacent(opt = {})
                        plural = opt.delete(:plural)
                        opt[:index] ||= 0 unless plural || opt.values.any? { |e| e.is_a? Regexp }
                        if !plural
                          el = Watir.element_class_for(opt[:tag_name] || '').new(self, opt)
                  Severity: Minor
                  Found in lib/watir/adjacent.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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      def wait_while_present(depr_timeout = nil, timeout: nil, interval: nil, message: nil)
                        timeout = depr_timeout if depr_timeout
                        Watir.logger.deprecate "#{self.class}#wait_while_present",
                                               "#{self.class}#wait_while(&:present?)",
                                               ids: [:wait_while_present]
                  Severity: Major
                  Found in lib/watir/wait.rb and 1 other location - About 1 hr to fix
                  lib/watir/wait.rb on lines 176..183

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 54.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      def wait_until_present(depr_timeout = nil, timeout: nil, interval: nil, message: nil)
                        timeout = depr_timeout if depr_timeout
                        Watir.logger.deprecate "#{self.class}#wait_until_present",
                                               "#{self.class}#wait_until(&:present?)",
                                               ids: [:wait_until_present]
                  Severity: Major
                  Found in lib/watir/wait.rb and 1 other location - About 1 hr to fix
                  lib/watir/wait.rb on lines 201..208

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 54.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                      def element_call(precondition = nil, &block)
                        caller = caller_locations(1, 1)[0].label
                        already_locked = browser.timer.locked?
                        browser.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 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

                    Severity
                    Category
                    Status
                    Source
                    Language