jnicklas/capybara

View on GitHub

Showing 68 of 68 total issues

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

      def description(applied = false)
        desc = +''
        if !applied || applied_filters
          desc << 'visible ' if visible == :visible
          desc << 'non-visible ' if visible == :hidden
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 process has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def process(method, path, attributes = {}, env = {})
    new_uri = URI.parse(path)
    method.downcase! unless method.is_a? Symbol
    if path.empty?
      new_uri.path = request_path
Severity: Minor
Found in lib/capybara/rack_test/browser.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 15 (exceeds 5 allowed). Consider refactoring.
Open

      def _check_with_label(selector, checked, locator, allow_label_click: session_options.automatic_label_click, **options)
        synchronize(Capybara::Queries::BaseQuery.wait(options, session_options.default_max_wait_time)) do
          begin
            el = find(selector, locator, options)
            el.set(checked)
Severity: Minor
Found in lib/capybara/node/actions.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 reset! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def reset!
    # Use instance variable directly so we avoid starting the browser just to reset the session
    return unless @browser

    navigated = false
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 add_input_param has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def add_input_param(field, params)
    if %w[radio checkbox].include? field['type']
      if field['checked']
        node = Capybara::RackTest::Node.new(driver, field)
        merge_param!(params, field['name'], node.value.to_s)
Severity: Minor
Found in lib/capybara/rack_test/form.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 synchronize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def synchronize(seconds = session_options.default_max_wait_time, errors: nil)
        return yield if session.synchronized

        session.synchronized = true
        timer = Capybara::Helpers.timer(expire_in: seconds)
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 click has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def click(keys = [], **options)
    click_options = ClickOptions.new(keys, options)
    return native.click if click_options.empty?
    scroll_if_needed do
      action_with_modifiers(click_options) do |action|
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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        class And < ::RSpec::Matchers::BuiltIn::Compound::And
        private

          def match(_expected, actual)
            @evaluator = CapybaraEvaluator.new(actual)
Severity: Major
Found in lib/capybara/rspec/compound.rb and 1 other location - About 1 hr to fix
lib/capybara/rspec/compound.rb on lines 64..88

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 52.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        class Or < ::RSpec::Matchers::BuiltIn::Compound::Or
        private

          def match(_expected, actual)
            @evaluator = CapybaraEvaluator.new(actual)
Severity: Major
Found in lib/capybara/rspec/compound.rb and 1 other location - About 1 hr to fix
lib/capybara/rspec/compound.rb on lines 36..60

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 52.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method _send_keys has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def _send_keys(keys, actions, down_keys = nil)
    case keys
    when String
      keys = keys.upcase if down_keys&.include?(:shift) # https://bugzilla.mozilla.org/show_bug.cgi?id=1405370
      actions.send_keys(keys)
Severity: Minor
Found in lib/capybara/selenium/nodes/marionette_node.rb - About 1 hr to fix

    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)
        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'
          case self[:type]
    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 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 compare_count has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def compare_count
          # Only check filters for as many elements as necessary to determine result
          if (count = @query.options[:count])
            count = Integer(count)
            return load_up_to(count + 1) <=> 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 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
          @app = app
    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 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_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_file(value) # rubocop:disable Naming/AccessorMethodName
        native.clear # By default files are appended so we have to clear here
        return super if browser_version >= 62.0
    
        # Workaround lack of support for multiple upload by uploading one at a time
    Severity: Minor
    Found in lib/capybara/selenium/nodes/marionette_node.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 click has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def click(keys = [], **offset)
        raise ArgumentError, 'The RackTest driver does not support click options' unless keys.empty? && offset.empty?
    
        if link?
          follow_link
    Severity: Minor
    Found in lib/capybara/rack_test/node.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

    Severity
    Category
    Status
    Source
    Language