lib/watir/locators/element/selector_builder/xpath.rb

Summary

Maintainability
A
3 hrs
Test Coverage

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

              def add_index(xpath, index)
                if @adjacent
                  "#{xpath}[#{index + 1}]"
                elsif index&.positive? && @built.empty?
                  "(#{xpath})[#{index + 1}]"
    Severity: Minor
    Found in lib/watir/locators/element/selector_builder/xpath.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 equal_pair has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def equal_pair(key, value)
                if key == :class
                  negate_xpath = value =~ /^!/ && value.slice!(0)
                  expression = "contains(concat(' ', @class, ' '), #{XpathSupport.escape " #{value} "})"
    
    
    Severity: Minor
    Found in lib/watir/locators/element/selector_builder/xpath.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 label_element_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def label_element_string
                label = @selector.delete :label_element
    
                return '' if label.nil?
    
    
    Severity: Minor
    Found in lib/watir/locators/element/selector_builder/xpath.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