flexirest/flexirest

View on GitHub

Showing 103 of 103 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 888 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 2 days to fix

    Method call has a Cognitive Complexity of 63 (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, quiet: quiet?) do
    Severity: Minor
    Found in lib/flexirest/request.rb - About 1 day 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 50 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_response(response, cached = nil)
          @response = response
          status = @response.status || 200
          if @response.body.blank? && !@method[:options][:ignore_empty_response]
            @response.response_headers['Content-Type'] = "application/json"
    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 prepare_params has a Cognitive Complexity of 48 (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 do_request has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        def do_request(etag)
          http_headers = {}
          http_headers["If-None-Match"] = etag if etag && !@method[:options][:skip_caching]
          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 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 generate_new_object has a Cognitive Complexity of 43 (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 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

    Class Request has 47 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 6 hrs to fix

      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

      Method write_cached_response has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

            def write_cached_response(request, response, result, quiet)
              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 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 set_corresponding_value has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_corresponding_value(value, key = nil, object = nil, overridden_name = nil)
            optional_args = [key, object, overridden_name]
            value_from_object = optional_args.all? # trying to parse a JSON Hash value
            value_from_other_type = optional_args.none? # trying to parse anything else
            raise Flexirest::InvalidArgumentsException.new("Optional args need all to be filled or none") unless value_from_object || value_from_other_type
      Severity: Minor
      Found in lib/flexirest/request.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

      File configuration.rb has 326 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 3 hrs to fix

        Method method_missing has a Cognitive Complexity of 25 (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 86 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, quiet: quiet?) do
        Severity: Major
        Found in lib/flexirest/request.rb - About 3 hrs to fix

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

              def do_request(etag)
                http_headers = {}
                http_headers["If-None-Match"] = etag if etag && !@method[:options][:skip_caching]
                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

            Class BaseWithoutValidation has 26 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 3 hrs to fix

              Method prepare_params has 74 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

                  Method handle_response has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def handle_response(response, cached = nil)
                        @response = response
                        status = @response.status || 200
                        if @response.body.blank? && !@method[:options][:ignore_empty_response]
                          @response.response_headers['Content-Type'] = "application/json"
                  Severity: Major
                  Found in lib/flexirest/request.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
                      Severity
                      Category
                      Status
                      Source
                      Language