teamcapybara/capybara

View on GitHub

Showing 116 of 116 total issues

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

module Capybara::Selenium::Driver::SafariDriver
  def switch_to_frame(frame)
    return super unless frame == :parent

    # safaridriver/safari has an issue where switch_to_frame(:parent)
Severity: Minor
Found in lib/capybara/selenium/driver_specializations/safari_driver.rb and 1 other location - About 55 mins to fix
lib/capybara/selenium/driver_specializations/internet_explorer_driver.rb on lines 5..19

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 44.

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 gather_hints has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
Open

      def gather_hints(elements, uses_visibility:, styles:, position:)
        hints_js, functions = build_hints_js(uses_visibility, styles, position)
        return [] unless functions.any?

        es_context.execute_script(hints_js, elements).map! do |results|
Severity: Minor
Found in lib/capybara/selenium/extensions/find.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

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

Method apply has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def apply(subject, value, skip_value, ctx, **options)
Severity: Minor
Found in lib/capybara/selector/filters/locator_filter.rb - About 35 mins to fix

    Method add_filter has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def add_filter(name, filter_class, *types, matcher: nil, **options, &block)
    Severity: Minor
    Found in lib/capybara/selector/filter_set.rb - About 35 mins to fix

      Method apply has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def apply(subject, name, value, skip_value, ctx)
      Severity: Minor
      Found in lib/capybara/selector/filters/base.rb - About 35 mins to fix

        Method set_text has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
        Open

          def set_text(value, clear: nil, rapid: nil, **_unused)
            value = value.to_s
            if value.empty? && clear.nil?
              native.clear
            elsif clear == :backspace
        Severity: Minor
        Found in lib/capybara/selenium/node.rb - About 35 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 function.
        Open

              return false;
        Severity: Major
        Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return containerState == OverflowState.HIDDEN ?
                      OverflowState.HIDDEN : OverflowState.SCROLL;
          Severity: Major
          Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return value ? "true" : null;
            Severity: Major
            Found in lib/capybara/selenium/atoms/src/getAttribute.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return false;
              Severity: Major
              Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return OverflowState.NONE;
                Severity: Major
                Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return false;
                  Severity: Major
                  Found in lib/capybara/selenium/atoms/src/isDisplayed.js - 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

                      Avoid too many return statements within this method.
                      Open

                              return size <=> min unless between.include?(size)
                      Severity: Major
                      Found in lib/capybara/result.rb - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return value != null ? value.toString() : null;
                        Severity: Major
                        Found in lib/capybara/selenium/atoms/src/getAttribute.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return !hiddenByOverflow(elem);
                          Severity: Major
                          Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return OverflowState.HIDDEN;
                            Severity: Major
                            Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    return parent && displayed(parent);
                              Severity: Major
                              Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                          return "true";
                                Severity: Major
                                Found in lib/capybara/selenium/atoms/src/getAttribute.js - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language