brynary/webrat

View on GitHub

Showing 24 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

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

                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

                  Method unescape_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def self.unescape_params(params)
                        case params.class.name
                        when 'Hash', 'Mash'
                          params.each { |key,value| params[key] = unescape_params(value) }
                          params
                  Severity: Minor
                  Found in lib/webrat/core/elements/form.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 matches_id? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def matches_id?(link)
                          if @value.is_a?(Regexp)
                            link["id"] =~ @value ? true : false
                          else
                            link["id"] == @value ? true : false
                  Severity: Minor
                  Found in lib/webrat/core/locators/link_locator.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 normalize_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def normalize_url(href) #:nodoc:
                        uri = URI.parse(href)
                        normalized_url = []
                        normalized_url << "#{uri.scheme}://" if uri.scheme
                        normalized_url << uri.host if uri.host
                  Severity: Minor
                  Found in lib/webrat/adapters/rails.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 click has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def click(options = {})
                        method = options[:method] || http_method
                        return if href =~ /^#/ && method == :get
                  
                        options[:javascript] = true if options[:javascript].nil?
                  Severity: Minor
                  Found in lib/webrat/core/elements/link.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

                  Severity
                  Category
                  Status
                  Source
                  Language