jnicklas/capybara

View on GitHub

Showing 57 of 57 total issues

Method extract_strings has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_strings(expression, alternation: false)
        strings = []
        expression.each do |exp| # rubocop:disable Metrics/BlockLength
          if optional?(exp) && !alternation
            strings.push(nil)
Severity: Minor
Found in lib/capybara/selector/regexp_disassembler.rb - About 5 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 description has a Cognitive Complexity of 18 (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 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 _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 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 compare_count has a Cognitive Complexity of 13 (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 matches_filters? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def matches_filters?(node, node_filter_errors = [])
        return true if (@resolved_node&.== node) && options[:allow_self]
        return false unless matches_locator_filter?(node)

        applied_filters << :system
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 extract_strings has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def extract_strings(expression, alternation: false)
        strings = []
        expression.each do |exp| # rubocop:disable Metrics/BlockLength
          if optional?(exp) && !alternation
            strings.push(nil)
Severity: Minor
Found in lib/capybara/selector/regexp_disassembler.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 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 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 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 [] has a Cognitive Complexity of 10 (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 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 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 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 text has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def text(type = nil, normalize_ws: false)
            type ||= :all unless session_options.ignore_hidden_elements || session_options.visible_text_only
            txt = synchronize { type == :all ? base.all_text : base.visible_text }
            normalize_ws ? txt.gsub(/[[:space:]]+/, ' ').strip : txt
          end
    Severity: Minor
    Found in lib/capybara/node/element.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

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

      def process_and_follow_redirects(method, path, attributes = {}, env = {})
        process(method, path, attributes, env)
    
        return unless driver.follow_redirects?
    
    
    Severity: Minor
    Found in lib/capybara/rack_test/browser.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