brynary/webrat

View on GitHub

Showing 35 of 35 total issues

Class Session has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Session
    extend Forwardable
    include Logging
    include SaveAndOpenPage

Severity: Minor
Found in lib/webrat/core/session.rb - About 4 hrs to fix

    File field.rb has 332 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "cgi"
    require "digest/md5"
    require "webrat/core_extensions/blank"
    require "webrat/core_extensions/nil_to_query_string"
    
    
    Severity: Minor
    Found in lib/webrat/core/elements/field.rb - About 4 hrs to fix

      Class SeleniumSession has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class SeleniumSession
          include Webrat::SaveAndOpenPage
          include Webrat::Selenium::SilenceStream
      
          def initialize(*args) # :nodoc:
      Severity: Minor
      Found in lib/webrat/selenium/selenium_session.rb - About 3 hrs to fix

        Class Scope has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Scope
            include Logging
            include Locators
        
            def self.from_page(session, response, response_body) #:nodoc:
        Severity: Minor
        Found in lib/webrat/core/scope.rb - About 2 hrs to fix

          Class Field has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Field < Element #:nodoc:
              attr_reader :value
          
              def self.xpath_search
                ".//button|.//input|.//textarea|.//select"
          Severity: Minor
          Found in lib/webrat/core/elements/field.rb - About 2 hrs to fix

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

              module Selenium
                module Matchers
                  class HaveSelector
                    def initialize(expected)
                      @expected = expected
            Severity: Major
            Found in lib/webrat/selenium/matchers/have_selector.rb and 1 other location - About 2 hrs to fix
            lib/webrat/selenium/matchers/have_xpath.rb on lines 2..49

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

            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

              module Selenium
                module Matchers
                  class HaveXpath
                    def initialize(expected)
                      @expected = expected
            Severity: Major
            Found in lib/webrat/selenium/matchers/have_xpath.rb and 1 other location - About 2 hrs to fix
            lib/webrat/selenium/matchers/have_selector.rb on lines 2..53

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

            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 replace_param_value has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.replace_param_value(params, oval, nval)
                  output = Hash.new
                  params.each do |key, value|
                    case value
                    when Hash
            Severity: Minor
            Found in lib/webrat/core/elements/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 wait_for has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def wait_for(params={})
                  timeout = params[:timeout] || 5
                  message = params[:message] || "Timeout exceeded"
            
                  begin_time = Time.now
            Severity: Minor
            Found in lib/webrat/selenium/selenium_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 adapter_class has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.adapter_class
                case Webrat.configuration.mode
                when :rails
                  RailsAdapter
                when :merb
            Severity: Minor
            Found in lib/webrat/core/session.rb - About 1 hr to fix

              Method locate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def locate
                      if @id_or_name_or_label
                        field = FieldLocator.new(@session, @dom, @id_or_name_or_label, SelectField, MultipleSelectField).locate!
              
                        field.options.detect do |o|
              Severity: Minor
              Found in lib/webrat/core/locators/select_option_locator.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 app_server_instance has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def self.app_server_instance
                      case Webrat.configuration.application_framework
                      when :sinatra
                        require "webrat/selenium/application_servers/sinatra"
                        return Webrat::Selenium::ApplicationServers::Sinatra.new
              Severity: Minor
              Found in lib/webrat/selenium/application_server_factory.rb - About 1 hr to fix

                Method build_query_string has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_query_string(escape_value=true)
                      if @value.is_a?(Array)
                        @value.collect {|value| "#{name}=#{ escape_value ? escape(value) : value }" }.join("&")
                      else
                        "#{name}=#{ escape_value ? escape(value) : value }"
                Severity: Minor
                Found in lib/webrat/core/elements/field.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 label_elements has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def label_elements
                      return @label_elements unless @label_elements.nil?
                      @label_elements = []
                
                      parent = @element.parent
                Severity: Minor
                Found in lib/webrat/core/elements/field.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 document has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.document(stringlike) #:nodoc:
                      return stringlike.dom if stringlike.respond_to?(:dom)
                
                      case stringlike
                      when Nokogiri::HTML::Document, Nokogiri::XML::NodeSet
                Severity: Minor
                Found in lib/webrat/core/xml.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

                Method request_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def request_page(url, http_method, data) #:nodoc:
                      h = headers
                      h['HTTP_REFERER'] = @current_url if @current_url
                
                      debug_log "REQUESTING PAGE: #{http_method.to_s.upcase} #{url} with #{data.inspect} and HTTP headers #{h.inspect}"
                Severity: Minor
                Found in lib/webrat/core/session.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

                Method select_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def select_date(date_to_select, options ={})
                      date = date_to_select.is_a?(Date) || date_to_select.is_a?(Time) ?
                                date_to_select : Date.parse(date_to_select)
                
                      id_prefix = locate_id_prefix(options) do
                Severity: Minor
                Found in lib/webrat/core/scope.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

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

                  if (candidateLink.id.toLowerCase().indexOf(locator.toLowerCase()) != -1) {
                    idMatched = true;
                  }
                Severity: Minor
                Found in lib/webrat/selenium/location_strategy_javascript/webratlink.js and 1 other location - About 35 mins to fix
                lib/webrat/selenium/location_strategy_javascript/webratlink.js on lines 12..14

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

                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 (candidateLink.title.toLowerCase().indexOf(locator.toLowerCase()) != -1) {
                    titleMatched = true;
                  }
                Severity: Minor
                Found in lib/webrat/selenium/location_strategy_javascript/webratlink.js and 1 other location - About 35 mins to fix
                lib/webrat/selenium/location_strategy_javascript/webratlink.js on lines 16..18

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

                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

                Avoid too many return statements within this method.
                Open

                          return Webrat::Selenium::ApplicationServers::External.new
                Severity: Major
                Found in lib/webrat/selenium/application_server_factory.rb - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language