teamcapybara/capybara

View on GitHub
lib/capybara/queries/selector_query.rb

Summary

Maintainability
D
2 days
Test Coverage

File selector_query.rb has 570 lines of code (exceeds 500 allowed). Consider refactoring.
Open

require 'matrix'

module Capybara
  module Queries
    class SelectorQuery < Queries::BaseQuery
Severity: Major
Found in lib/capybara/queries/selector_query.rb - About 3 hrs to fix

    Method description has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
    Open

          def description(only_applied = false) # rubocop:disable Style/OptionalBooleanParameter
            desc = +''
            show_for = show_for_stage(only_applied)
    
            if show_for[:any]
    Severity: Minor
    Found in lib/capybara/queries/selector_query.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 matches_spatial_filters? has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
    Open

          def matches_spatial_filters?(node)
            applied_filters << :spatial
            return true unless use_spatial_filter?
    
            node_rect = Rectangle.new(node.initial_cache[:position] || node.rect)
    Severity: Minor
    Found in lib/capybara/queries/selector_query.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 distance_segment_segment has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def distance_segment_segment(l1p1, l1p2, l2p1, l2p2)
              # See http://geomalgorithms.com/a07-_distance.html
              # rubocop:disable Naming/VariableName
              u = l1p2 - l1p1
              v = l2p2 - l2p1
    Severity: Major
    Found in lib/capybara/queries/selector_query.rb - About 2 hrs to fix

      Method distance_segment_segment has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
      Open

              def distance_segment_segment(l1p1, l1p2, l2p1, l2p2)
                # See http://geomalgorithms.com/a07-_distance.html
                # rubocop:disable Naming/VariableName
                u = l1p2 - l1p1
                v = l2p2 - l2p1
      Severity: Minor
      Found in lib/capybara/queries/selector_query.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 description has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def description(only_applied = false) # rubocop:disable Style/OptionalBooleanParameter
              desc = +''
              show_for = show_for_stage(only_applied)
      
              if show_for[:any]
      Severity: Minor
      Found in lib/capybara/queries/selector_query.rb - About 1 hr to fix

        Method find_nodes_by_selector_format has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
        Open

              def find_nodes_by_selector_format(node, exact)
                hints = {}
                hints[:uses_visibility] = true unless visible == :all
                hints[:texts] = text_fragments unless selector_format == :xpath
                hints[:styles] = options[:style] if use_default_style_filter?
        Severity: Minor
        Found in lib/capybara/queries/selector_query.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

        Avoid too many return statements within this method.
        Open

                  return false unless node_rect.near? el_rect
        Severity: Major
        Found in lib/capybara/queries/selector_query.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return false unless node_rect.right_of? el_rect
          Severity: Major
          Found in lib/capybara/queries/selector_query.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return false if node == options[:near]
            Severity: Major
            Found in lib/capybara/queries/selector_query.rb - About 30 mins to fix

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

                    def matches_node_filters?(node, errors)
                      applied_filters << :node
              
                      unapplied_options = options.keys - valid_keys
                      @selector.with_filter_errors(errors) do
              Severity: Minor
              Found in lib/capybara/queries/selector_query.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