teamcapybara/capybara

View on GitHub
lib/capybara/node/actions.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method _check_with_label has a Cognitive Complexity of 16 (exceeds 10 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 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 attach_file has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

      def attach_file(locator = nil, paths, make_visible: nil, **options) # rubocop:disable Style/OptionalArguments
        if locator && block_given?
          raise ArgumentError, '``#attach_file` does not support passing both a locator and a block'
        end

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

Do not suppress exceptions.
Open

      rescue StandardError # rubocop:disable Lint/SuppressedException swallow extra errors
Severity: Minor
Found in lib/capybara/node/actions.rb by rubocop

This cop checks for rescue blocks with no body.

Example: AllowComments: false (default)

# bad
def some_method
  do_something
rescue
end

# bad
def some_method
  do_something
rescue
  # do nothing
end

# bad
begin
  do_something
rescue
end

# bad
begin
  do_something
rescue
  # do nothing
end

# good
def some_method
  do_something
rescue
  handle_exception
end

# good
begin
  do_something
rescue
  handle_exception
end

Example: AllowComments: true

# bad
def some_method
  do_something
rescue
end

# bad
begin
  do_something
rescue
end

# good
def some_method
  do_something
rescue
  # do nothing but comment
end

# good
begin
  do_something
rescue
  # do nothing but comment
end

There are no issues that match your filters.

Category
Status