teamcapybara/capybara

View on GitHub

Showing 119 of 119 total issues

Function getOverflowState has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function getOverflowState(elem) {
    var region = getClientRegion(elem);
    var ownerDoc = elem.ownerDocument;
    var htmlElem = ownerDoc.documentElement;
    var bodyElem = ownerDoc.body;
Severity: Major
Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 4 hrs to fix

    File selector_query.rb has 570 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    require 'matrix'
    
    module Capybara
      module Queries
        class SelectorQuery < Queries::BaseQuery
    Severity: Major
    Found in lib/capybara/queries/selector_query.rb - About 3 hrs to fix

      Method description has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
      Open

            def description(only_applied = false) # rubocop:disable Style/OptionalBooleanParameter
              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 matches_spatial_filters? has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
      Open

            def matches_spatial_filters?(node)
              applied_filters << :spatial
              return true unless use_spatial_filter?
      
              node_rect = Rectangle.new(node.initial_cache[:position] || node.rect)
      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

      Function isShown_ has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function isShown_(elem, ignoreOpacity, parentsDisplayedFn) {
          // By convention, BODY element is always shown: BODY represents the document
          // and even if there's nothing rendered in there, user can always see there's
          // the document.
          var elemTagName = elem.tagName.toUpperCase();
      Severity: Major
      Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 2 hrs to fix

        Method synchronize has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
        Open

              def synchronize(seconds = nil, errors: nil)
                return yield if session.synchronized
        
                seconds = session_options.default_max_wait_time if [nil, true].include? seconds
                session.synchronized = true
        Severity: Minor
        Found in lib/capybara/node/base.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 distance_segment_segment has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def distance_segment_segment(l1p1, l1p2, l2p1, l2p2)
                  # See http://geomalgorithms.com/a07-_distance.html
                  # rubocop:disable Naming/VariableName
                  u = l1p2 - l1p1
                  v = l2p2 - l2p1
        Severity: Major
        Found in lib/capybara/queries/selector_query.rb - About 2 hrs to fix

          Function get has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            return function get(element, attribute){
              var value = null;
              var name = attribute.toLowerCase();
          
              if ("style" == name) {
          Severity: Minor
          Found in lib/capybara/selenium/atoms/src/getAttribute.js - About 2 hrs to fix

            Method distance_segment_segment has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
            Open

                    def distance_segment_segment(l1p1, l1p2, l2p1, l2p2)
                      # See http://geomalgorithms.com/a07-_distance.html
                      # rubocop:disable Naming/VariableName
                      u = l1p2 - l1p1
                      v = l2p2 - l2p1
            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 click has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
            Open

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

            Method compare_count has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
            Open

                def compare_count
                  return 0 unless @query
            
                  count, min, max, between = @query.options.values_at(:count, :minimum, :maximum, :between)
            
            
            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 description has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def description(only_applied = false) # rubocop:disable Style/OptionalBooleanParameter
                    desc = +''
                    show_for = show_for_stage(only_applied)
            
                    if show_for[:any]
            Severity: Minor
            Found in lib/capybara/queries/selector_query.rb - About 1 hr to fix

              Method build_hints_js has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def build_hints_js(uses_visibility, styles, position)
                      functions = []
                      hints_js = +''
              
                      if uses_visibility && !is_displayed_atom.empty?
              Severity: Minor
              Found in lib/capybara/selenium/extensions/find.rb - About 1 hr to fix

                Method set has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def set(value, **options)
                    if value.is_a?(Array) && !multiple?
                      raise ArgumentError, "Value cannot be an Array when 'multiple' attribute is not present. Not a #{value.class}"
                    end
                
                
                Severity: Minor
                Found in lib/capybara/selenium/node.rb - About 1 hr to fix

                  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

                  Method [] has a Cognitive Complexity of 15 (exceeds 10 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

                  Function getOverflowParent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function getOverflowParent(e) {
                        function canBeOverflowed(container) {
                          // The HTML element can always be overflowed.
                          if (container == htmlElem) {
                            return true;
                  Severity: Minor
                  Found in lib/capybara/selenium/atoms/src/isDisplayed.js - About 1 hr to fix

                    Method build_uri has a Cognitive Complexity of 14 (exceeds 10 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 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

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

                    module Capybara::Selenium::Driver::InternetExplorerDriver
                      def switch_to_frame(frame)
                        return super unless frame == :parent
                    
                        # iedriverserver has an issue if the current frame is removed from within it
                    lib/capybara/selenium/driver_specializations/safari_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

                    Severity
                    Category
                    Status
                    Source
                    Language