flexirest/flexirest

View on GitHub

Showing 74 of 91 total issues

Method valid? has a Cognitive Complexity of 161 (exceeds 5 allowed). Consider refactoring.
Open

    def valid?
      @errors = Hash.new {|h,k| h[k] = []}
      self.class._validations.each do |validation|
        value = self.send(validation[:field_name])
        allow_nil = validation[:options].fetch(:allow_nil, false)
Severity: Minor
Found in lib/flexirest/validation.rb - About 3 days 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

File request.rb has 781 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "cgi"
require "multi_json"
require 'crack'
require 'crack/xml'

Severity: Major
Found in lib/flexirest/request.rb - About 1 day to fix

    Method prepare_params has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        def prepare_params
          if http_method == :post || http_method == :put || http_method == :patch
            params = (@object._attributes rescue {}).merge(@params || {}) rescue {}
          else
            params = @params || @object._attributes rescue {}
    Severity: Minor
    Found in lib/flexirest/request.rb - About 7 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 call has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        def call(explicit_parameters=nil)
          @instrumentation_name = "#{class_name}##{@method[:name]}"
          result = nil
          cached = nil
          ActiveSupport::Notifications.instrument("request_call.flexirest", :name => @instrumentation_name) do
    Severity: Minor
    Found in lib/flexirest/request.rb - About 6 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 do_request has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_request(etag)
          http_headers = {}
          http_headers["If-None-Match"] = etag if etag
          http_headers["Accept"] = "application/hal+json, application/json;q=0.5"
          headers.each do |key,value|
    Severity: Minor
    Found in lib/flexirest/request.rb - About 5 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 new_object has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        def new_object(attributes, name = nil)
          @method[:options][:has_many] ||= {}
          name = name.to_sym rescue nil
          if @method[:options][:has_many][name]
            overridden_name = name
    Severity: Minor
    Found in lib/flexirest/request.rb - About 5 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 prepare_request_body has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        def prepare_request_body(params = nil)
          if proxy == :json_api
            if http_method == :get || (http_method == :delete && !@method[:options][:send_delete_body])
              @body = ""
            else
    Severity: Minor
    Found in lib/flexirest/request.rb - About 5 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

    Class Request has 39 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Request
        include AttributeParsing
        include JsonAPIProxy
        include ActiveSupport::Inflector
        attr_accessor :post_params, :get_params, :url, :path, :headers, :method, :object, :body, :forced_url, :original_url, :retrying
    Severity: Minor
    Found in lib/flexirest/request.rb - About 5 hrs to fix

      Method generate_new_object has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def generate_new_object(options={})
            if @response.body.is_a?(Array) || @response.body.is_a?(Hash)
              body = @response.body
            elsif is_json_response?
              begin
      Severity: Minor
      Found in lib/flexirest/request.rb - About 4 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 handle_response has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_response(response, cached = nil)
            @response = response
            status = @response.status || 200
            if @response.body.blank?
              @response.response_headers['Content-Type'] = "application/json"
      Severity: Minor
      Found in lib/flexirest/request.rb - About 4 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 method_missing has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def method_missing(name, *args)
            if name.to_s[-1,1] == "="
              name = name.to_s.chop.to_sym
              _set_attribute(name, args.first)
            else
      Severity: Minor
      Found in lib/flexirest/base_without_validation.rb - About 3 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 call has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def call(explicit_parameters=nil)
            @instrumentation_name = "#{class_name}##{@method[:name]}"
            result = nil
            cached = nil
            ActiveSupport::Notifications.instrument("request_call.flexirest", :name => @instrumentation_name) do
      Severity: Major
      Found in lib/flexirest/request.rb - About 3 hrs to fix

        Method do_request has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def do_request(etag)
              http_headers = {}
              http_headers["If-None-Match"] = etag if etag
              http_headers["Accept"] = "application/hal+json, application/json;q=0.5"
              headers.each do |key,value|
        Severity: Major
        Found in lib/flexirest/request.rb - About 3 hrs to fix

          Method prepare_params has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def prepare_params
                if http_method == :post || http_method == :put || http_method == :patch
                  params = (@object._attributes rescue {}).merge(@params || {}) rescue {}
                else
                  params = @params || @object._attributes rescue {}
          Severity: Major
          Found in lib/flexirest/request.rb - About 2 hrs to fix

            Method valid? has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def valid?
                  @errors = Hash.new {|h,k| h[k] = []}
                  self.class._validations.each do |validation|
                    value = self.send(validation[:field_name])
                    allow_nil = validation[:options].fetch(:allow_nil, false)
            Severity: Major
            Found in lib/flexirest/validation.rb - About 2 hrs to fix

              Class BaseWithoutValidation has 25 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class BaseWithoutValidation
                  include Mapping
                  include Configuration
                  include Callbacks
                  include Caching
              Severity: Minor
              Found in lib/flexirest/base_without_validation.rb - About 2 hrs to fix

                Method prepare_request_body has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def prepare_request_body(params = nil)
                      if proxy == :json_api
                        if http_method == :get || (http_method == :delete && !@method[:options][:send_delete_body])
                          @body = ""
                        else
                Severity: Major
                Found in lib/flexirest/request.rb - About 2 hrs to fix

                  File configuration.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'cgi'
                  
                  module Flexirest
                    module Configuration
                      module ClassMethods
                  Severity: Minor
                  Found in lib/flexirest/configuration.rb - About 2 hrs to fix

                    Method username has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def username(value = nil, &block)
                            @username ||= nil
                            @@username ||= nil
                            if value.nil?
                              if block_given?
                    Severity: Minor
                    Found in lib/flexirest/configuration.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 write_cached_response has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def write_cached_response(request, response, result)
                            return if result.is_a? Symbol
                            return unless perform_caching
                            return unless !result.respond_to?(:_status) || [200, 304].include?(result._status)
                            headers = response.response_headers
                    Severity: Minor
                    Found in lib/flexirest/caching.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

                    Severity
                    Category
                    Status
                    Source
                    Language