teamcapybara/capybara

View on GitHub

Showing 116 of 116 total issues

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 method.
    Open

              return false unless node_rect.near? el_rect
    Severity: Major
    Found in lib/capybara/queries/selector_query.rb - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return element[name] + "";
      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 method.
          Open

                    return false unless node_rect.right_of? el_rect
          Severity: Major
          Found in lib/capybara/queries/selector_query.rb - 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

              Method matches_node_filters? has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
              Open

                    def matches_node_filters?(node, errors)
                      applied_filters << :node
              
                      unapplied_options = options.keys - valid_keys
                      @selector.with_filter_errors(errors) do
              Severity: Minor
              Found in lib/capybara/queries/selector_query.rb - About 25 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 11 (exceeds 10 allowed). Consider refactoring.
              Open

                    def all(*args, allow_reload: false, **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 25 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 extract_strings has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
              Open

                      def extract_strings(process_alternatives)
                        strings = []
                        each do |exp|
                          next if exp.ignore?
              
              
              Severity: Minor
              Found in lib/capybara/selector/regexp_disassembler.rb - About 25 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 set has a Cognitive Complexity of 11 (exceeds 10 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 25 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 synced_resolve has a Cognitive Complexity of 11 (exceeds 10 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 25 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

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

                def visible?
                  return super unless native_displayed?
              
                  begin
                    bridge.send(:execute, :is_element_displayed, id: native.ref)
              Severity: Minor
              Found in lib/capybara/selenium/nodes/chrome_node.rb and 1 other location - About 20 mins to fix
              lib/capybara/selenium/nodes/firefox_node.rb on lines 70..79

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

              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

                    if RUBY_VERSION >= '2.7'
                      class_eval <<~METHOD, __FILE__, __LINE__ + 1
                        def #{method}(...)
                          page.method("#{method}").call(...)
                        end
              Severity: Minor
              Found in lib/capybara/dsl.rb and 1 other location - About 20 mins to fix
              lib/capybara/session.rb on lines 766..774

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

              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

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

                def visible?
                  return super unless native_displayed?
              
                  begin
                    bridge.send(:execute, :is_element_displayed, id: native.ref)
              Severity: Minor
              Found in lib/capybara/selenium/nodes/firefox_node.rb and 1 other location - About 20 mins to fix
              lib/capybara/selenium/nodes/chrome_node.rb on lines 64..73

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

              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

                    if RUBY_VERSION >= '2.7'
                      class_eval <<~METHOD, __FILE__, __LINE__ + 1
                        def #{method}(...)
                          document.#{method}(...)
                        end
              Severity: Minor
              Found in lib/capybara/session.rb and 1 other location - About 20 mins to fix
              lib/capybara/dsl.rb on lines 50..59

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

              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

              Do not suppress exceptions.
              Open

                rescue Selenium::WebDriver::Error::SessionNotCreatedError, Errno::ECONNREFUSED
              Severity: Minor
              Found in lib/capybara/selenium/driver.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

              Method parameter must be at least 3 characters long.
              Open

                    def scroll_to(pos_or_el_or_x, y = nil, align: :top, offset: nil)
              Severity: Minor
              Found in lib/capybara/node/element.rb by rubocop

              This cop checks method parameter names for how descriptive they are. It is highly configurable.

              The MinNameLength config option takes an integer. It represents the minimum amount of characters the name must be. Its default is 3. The AllowNamesEndingInNumbers config option takes a boolean. When set to false, this cop will register offenses for names ending with numbers. Its default is false. The AllowedNames config option takes an array of whitelisted names that will never register an offense. The ForbiddenNames config option takes an array of blacklisted names that will always register an offense.

              Example:

              # bad
              def bar(varOne, varTwo)
                varOne + varTwo
              end
              
              # With `AllowNamesEndingInNumbers` set to false
              def foo(num1, num2)
                num1 * num2
              end
              
              # With `MinArgNameLength` set to number greater than 1
              def baz(a, b, c)
                do_stuff(a, b, c)
              end
              
              # good
              def bar(thud, fred)
                thud + fred
              end
              
              def foo(speed, distance)
                speed * distance
              end
              
              def baz(age_a, height_b, gender_c)
                do_stuff(age_a, height_b, gender_c)
              end

              Method parameter must be at least 3 characters long.
              Open

                      def element_matches?(el)

              This cop checks method parameter names for how descriptive they are. It is highly configurable.

              The MinNameLength config option takes an integer. It represents the minimum amount of characters the name must be. Its default is 3. The AllowNamesEndingInNumbers config option takes a boolean. When set to false, this cop will register offenses for names ending with numbers. Its default is false. The AllowedNames config option takes an array of whitelisted names that will never register an offense. The ForbiddenNames config option takes an array of blacklisted names that will always register an offense.

              Example:

              # bad
              def bar(varOne, varTwo)
                varOne + varTwo
              end
              
              # With `AllowNamesEndingInNumbers` set to false
              def foo(num1, num2)
                num1 * num2
              end
              
              # With `MinArgNameLength` set to number greater than 1
              def baz(a, b, c)
                do_stuff(a, b, c)
              end
              
              # good
              def bar(thud, fred)
                thud + fred
              end
              
              def foo(speed, distance)
                speed * distance
              end
              
              def baz(age_a, height_b, gender_c)
                do_stuff(age_a, height_b, gender_c)
              end

              Method parameter must be at least 3 characters long.
              Open

                      def element_does_not_match?(el)

              This cop checks method parameter names for how descriptive they are. It is highly configurable.

              The MinNameLength config option takes an integer. It represents the minimum amount of characters the name must be. Its default is 3. The AllowNamesEndingInNumbers config option takes a boolean. When set to false, this cop will register offenses for names ending with numbers. Its default is false. The AllowedNames config option takes an array of whitelisted names that will never register an offense. The ForbiddenNames config option takes an array of blacklisted names that will always register an offense.

              Example:

              # bad
              def bar(varOne, varTwo)
                varOne + varTwo
              end
              
              # With `AllowNamesEndingInNumbers` set to false
              def foo(num1, num2)
                num1 * num2
              end
              
              # With `MinArgNameLength` set to number greater than 1
              def baz(a, b, c)
                do_stuff(a, b, c)
              end
              
              # good
              def bar(thud, fred)
                thud + fred
              end
              
              def foo(speed, distance)
                speed * distance
              end
              
              def baz(age_a, height_b, gender_c)
                do_stuff(age_a, height_b, gender_c)
              end

              Method parameter must be at least 3 characters long.
              Open

                    def above(el)

              This cop checks method parameter names for how descriptive they are. It is highly configurable.

              The MinNameLength config option takes an integer. It represents the minimum amount of characters the name must be. Its default is 3. The AllowNamesEndingInNumbers config option takes a boolean. When set to false, this cop will register offenses for names ending with numbers. Its default is false. The AllowedNames config option takes an array of whitelisted names that will never register an offense. The ForbiddenNames config option takes an array of blacklisted names that will always register an offense.

              Example:

              # bad
              def bar(varOne, varTwo)
                varOne + varTwo
              end
              
              # With `AllowNamesEndingInNumbers` set to false
              def foo(num1, num2)
                num1 * num2
              end
              
              # With `MinArgNameLength` set to number greater than 1
              def baz(a, b, c)
                do_stuff(a, b, c)
              end
              
              # good
              def bar(thud, fred)
                thud + fred
              end
              
              def foo(speed, distance)
                speed * distance
              end
              
              def baz(age_a, height_b, gender_c)
                do_stuff(age_a, height_b, gender_c)
              end
              Severity
              Category
              Status
              Source
              Language