flexirest/flexirest

View on GitHub
lib/flexirest/request.rb

Summary

Maintainability
F
1 wk
Test Coverage

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

      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

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

                Method handle_hal_links_embedded has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def handle_hal_links_embedded(object, attributes)
                      attributes["_links"] = attributes[:_links] if attributes[:_links]
                      attributes["_embedded"] = attributes[:_embedded] if attributes[:_embedded]
                      if attributes["_links"]
                        attributes["_links"].each do |key, value|
                Severity: Minor
                Found in lib/flexirest/request.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 generate_new_object has 50 lines of code (exceeds 25 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 2 hrs to fix

                  Method prepare_url has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def prepare_url
                        missing = []
                        if @forced_url && @forced_url.present?
                          @url = @forced_url
                        else
                  Severity: Minor
                  Found in lib/flexirest/request.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 set_corresponding_value has 38 lines of code (exceeds 25 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 1 hr to fix

                    Method new_object has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

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

                        def hal_response?
                          _, content_type = @response.response_headers.detect{|k,v| k.downcase == "content-type"}
                          faked_response = @response.response_headers.detect{|k,v| k.downcase == "x-arc-faked-response"}
                          if content_type && content_type.respond_to?(:each)
                            content_type.each do |ct|
                    Severity: Minor
                    Found in lib/flexirest/request.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 handle_hal_links_embedded has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def handle_hal_links_embedded(object, attributes)
                          attributes["_links"] = attributes[:_links] if attributes[:_links]
                          attributes["_embedded"] = attributes[:_embedded] if attributes[:_embedded]
                          if attributes["_links"]
                            attributes["_links"].each do |key, value|
                    Severity: Minor
                    Found in lib/flexirest/request.rb - About 1 hr to fix

                      Method new_object has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def new_object(attributes, name = nil, parent = nil, parent_attribute_name = nil)
                            @method[:options][:has_many] ||= {}
                            name = name.to_sym rescue nil
                            if @method[:options][:has_many][name]
                              parent_name = name
                      Severity: Minor
                      Found in lib/flexirest/request.rb - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                @body ||= if params.is_a?(String)
                                  params
                                elsif @post_params.is_a?(String)
                                  @post_params
                                else
                        Severity: Major
                        Found in lib/flexirest/request.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if @object.changes.has_key? changed_attr.to_sym
                                          newPostHash[changed_attr.to_sym] = @object[changed_attr.to_sym]
                                        end
                          Severity: Major
                          Found in lib/flexirest/request.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      if wrap_root.present?
                                        p = {wrap_root => p}
                                      end
                            Severity: Major
                            Found in lib/flexirest/request.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                    elsif request_body_type == :json
                                      @body ||= if params.is_a?(String)
                                        params
                                      elsif @post_params.is_a?(String)
                                        @post_params
                              Severity: Major
                              Found in lib/flexirest/request.rb - About 45 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                      if @forced_url && @forced_url.present?
                                        @url = @forced_url
                                      else
                                        @url = @method[:url].dup
                                        matches = @url.scan(/(:[a-z_-]+)/)
                                Severity: Major
                                Found in lib/flexirest/request.rb - About 40 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return result if response.finished?
                                  Severity: Major
                                  Found in lib/flexirest/request.rb - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return @response_delegate
                                    Severity: Major
                                    Found in lib/flexirest/request.rb - About 30 mins to fix

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

                                          def api_auth_access_id
                                            ret = nil
                                            if object_is_class?
                                              ret = @object.api_auth_access_id
                                              ret = ret.call if ret.respond_to?(:call)
                                      Severity: Minor
                                      Found in lib/flexirest/request.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 username has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def username
                                            ret = nil
                                            if object_is_class?
                                              ret = @object.username
                                              ret = ret.call if ret.respond_to?(:call)
                                      Severity: Minor
                                      Found in lib/flexirest/request.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 password has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def password
                                            ret = nil
                                            if object_is_class?
                                              ret = @object.password
                                              ret = ret.call if ret.respond_to?(:call)
                                      Severity: Minor
                                      Found in lib/flexirest/request.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 api_auth_secret_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def api_auth_secret_key
                                            ret = nil
                                            if object_is_class?
                                              ret = @object.api_auth_secret_key
                                              ret = ret.call if ret.respond_to?(:call)
                                      Severity: Minor
                                      Found in lib/flexirest/request.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

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

                                          def api_auth_access_id
                                            ret = nil
                                            if object_is_class?
                                              ret = @object.api_auth_access_id
                                              ret = ret.call if ret.respond_to?(:call)
                                      Severity: Minor
                                      Found in lib/flexirest/request.rb and 3 other locations - About 25 mins to fix
                                      lib/flexirest/request.rb on lines 87..96
                                      lib/flexirest/request.rb on lines 107..116
                                      lib/flexirest/request.rb on lines 119..128

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

                                      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 4 locations. Consider refactoring.
                                      Open

                                          def password
                                            ret = nil
                                            if object_is_class?
                                              ret = @object.password
                                              ret = ret.call if ret.respond_to?(:call)
                                      Severity: Minor
                                      Found in lib/flexirest/request.rb and 3 other locations - About 25 mins to fix
                                      lib/flexirest/request.rb on lines 75..84
                                      lib/flexirest/request.rb on lines 87..96
                                      lib/flexirest/request.rb on lines 107..116

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

                                      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 4 locations. Consider refactoring.
                                      Open

                                          def username
                                            ret = nil
                                            if object_is_class?
                                              ret = @object.username
                                              ret = ret.call if ret.respond_to?(:call)
                                      Severity: Minor
                                      Found in lib/flexirest/request.rb and 3 other locations - About 25 mins to fix
                                      lib/flexirest/request.rb on lines 75..84
                                      lib/flexirest/request.rb on lines 87..96
                                      lib/flexirest/request.rb on lines 119..128

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

                                      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 4 locations. Consider refactoring.
                                      Open

                                          def api_auth_secret_key
                                            ret = nil
                                            if object_is_class?
                                              ret = @object.api_auth_secret_key
                                              ret = ret.call if ret.respond_to?(:call)
                                      Severity: Minor
                                      Found in lib/flexirest/request.rb and 3 other locations - About 25 mins to fix
                                      lib/flexirest/request.rb on lines 75..84
                                      lib/flexirest/request.rb on lines 107..116
                                      lib/flexirest/request.rb on lines 119..128

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

                                      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

                                      There are no issues that match your filters.

                                      Category
                                      Status