lib/watir/elements/element.rb

Summary

Maintainability
D
2 days
Test Coverage

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

    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

      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 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 check_condition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_condition(condition, caller)
              Watir.logger.debug "<- `Verifying precondition #{inspect}##{condition} for #{caller}`"
              begin
                condition.nil? ? assert_exists : send(condition)
                Watir.logger.debug "<- `Verified precondition #{inspect}##{condition || 'assert_exists'}`"
        Severity: Minor
        Found in lib/watir/elements/element.rb - About 45 mins 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 wait_for_enabled has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def wait_for_enabled
              return assert_enabled unless Watir.relaxed_locate?
        
              wait_for_exists
              return unless [Input, Button, Select, Option].any? { |c| is_a? c } || @content_editable
        Severity: Minor
        Found in lib/watir/elements/element.rb - About 35 mins 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(query_scope, selector)
              @query_scope = query_scope
        
              raise ArgumentError, "invalid argument: #{selector.inspect}" unless selector.is_a? Hash
        
        
        Severity: Minor
        Found in lib/watir/elements/element.rb - About 25 mins 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 wait_for_writable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def wait_for_writable
              wait_for_enabled
              unless Watir.relaxed_locate?
                raise_writable unless !respond_to?(:readonly?) || !readonly?
              end
        Severity: Minor
        Found in lib/watir/elements/element.rb - About 25 mins 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 wait_for_exists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def wait_for_exists
              return assert_exists unless Watir.relaxed_locate?
              return if located? # Performance shortcut
        
              begin
        Severity: Minor
        Found in lib/watir/elements/element.rb - About 25 mins 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

        There are no issues that match your filters.

        Category
        Status