jnicklas/capybara

View on GitHub

Showing 73 of 73 total issues

Method description has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

      def description(only_applied = false)
        desc = +''
        show_for = show_for_stage(only_applied)

        if show_for[:any]
Severity: Minor
Found in lib/capybara/queries/selector_query.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_by has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def find_by(format, selector, uses_visibility:, texts:, styles:)
        els = find_context.find_elements(format, selector)
        hints = []

        if (els.size > 2) && !ENV['DISABLE_CAPYBARA_SELENIUM_OPTIMIZATIONS']
Severity: Minor
Found in lib/capybara/selenium/extensions/find.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 _check_with_label has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def _check_with_label(selector, checked, locator,
                            allow_label_click: session_options.automatic_label_click, **options)
        options[:allow_self] = true if locator.nil?

        synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
Severity: Minor
Found in lib/capybara/node/actions.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 compare_count has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def compare_count
      count, min, max, between = @query.options.values_at(:count, :minimum, :maximum, :between)

      # Only check filters for as many elements as necessary to determine result
      if count && (count = Integer(count))
Severity: Minor
Found in lib/capybara/result.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 find_nodes_by_selector_format has a Cognitive Complexity of 14 (exceeds 5 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 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 build_uri has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def build_uri(path)
    URI.parse(path).tap do |uri|
      uri.path = request_path if path.empty? || path.start_with?('?')
      uri.path = '/' if uri.path.empty?
      uri.path = request_path.sub(%r{/[^/]*$}, '/') + uri.path unless uri.path.start_with?('/')
Severity: Minor
Found in lib/capybara/rack_test/browser.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 add_attribute_conditions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def add_attribute_conditions(**attributes)
        @expression = attributes.inject(expression) do |css, (name, value)|
          conditions = if name == :class
            class_conditions(value)
          elsif value.is_a? Regexp
Severity: Minor
Found in lib/capybara/selector/builders/css_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 find_by has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def find_by(format, selector, uses_visibility:, texts:, styles:)
        els = find_context.find_elements(format, selector)
        hints = []

        if (els.size > 2) && !ENV['DISABLE_CAPYBARA_SELENIUM_OPTIMIZATIONS']
Severity: Minor
Found in lib/capybara/selenium/extensions/find.rb - About 1 hr to fix

    Method synchronize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def synchronize(seconds = nil, errors: nil)
            return yield if session.synchronized
    
            seconds = session_options.default_max_wait_time if seconds.nil?
            session.synchronized = true
    Severity: Minor
    Found in lib/capybara/node/base.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 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def description(only_applied = false)
            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 synced_resolve has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def synced_resolve(query)
              synchronize(query.wait) do
                if prefer_exact?(query)
                  result = query.resolve_for(self, true)
                  result = query.resolve_for(self, false) if result.empty? && query.supports_exact? && !query.exact?
      Severity: Minor
      Found in lib/capybara/node/finders.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 [] has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def [](*args)
            idx, length = args
            max_idx = case idx
            when Integer
              if !idx.negative?
      Severity: Minor
      Found in lib/capybara/result.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(mode, app = nil)
            raise TypeError, 'The second parameter to Session::new should be a rack app if passed.' if app && !app.respond_to?(:call)
      
            @@instance_created = true
            @mode = mode
      Severity: Minor
      Found in lib/capybara/session.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 failure_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def failure_message
            message = @query.failure_message
            if count.zero?
              message << ' but there were no matches'
            else
      Severity: Minor
      Found in lib/capybara/result.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 set has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def set(value, **options)
          return if disabled? || readonly?
      
          warn "Options passed to Node#set but the RackTest driver doesn't support any - ignoring" unless options.empty?
      
      
      Severity: Minor
      Found in lib/capybara/rack_test/node.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 find_modal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_modal(text: nil, **options)
          # Selenium has its own built in wait (2 seconds)for a modal to show up, so this wait is really the minimum time
          # Actual wait time may be longer than specified
          wait = Selenium::WebDriver::Wait.new(
            timeout: options.fetch(:wait, session_options.default_max_wait_time) || 0,
      Severity: Minor
      Found in lib/capybara/selenium/driver.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 attribute_conditions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def attribute_conditions(attributes)
              attributes.map do |attribute, value|
                case value
                when XPath::Expression
                  raise ArgumentError, "XPath expressions are not supported for the :#{attribute} filter with CSS based selectors"
      Severity: Minor
      Found in lib/capybara/selector/builders/css_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 set has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def set(value, **options)
          raise ArgumentError, "Value cannot be an Array when 'multiple' attribute is not present. Not a #{value.class}" if value.is_a?(Array) && !multiple?
      
          case tag_name
          when 'input'
      Severity: Minor
      Found in lib/capybara/selenium/node.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 value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def value
              if tag_name == 'textarea'
                native['_capybara_raw_value']
              elsif tag_name == 'select'
                selected_options = find_xpath('.//option[@selected]')
      Severity: Minor
      Found in lib/capybara/node/simple.rb - About 55 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 all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def all(*args, **options, &optional_filter_block)
              minimum_specified = options_include_minimum?(options)
              options = { minimum: 1 }.merge(options) unless minimum_specified
              options[:session_options] = session_options
              query = Capybara::Queries::SelectorQuery.new(*args, options, &optional_filter_block)
      Severity: Minor
      Found in lib/capybara/node/finders.rb - About 55 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

      Severity
      Category
      Status
      Source
      Language