flexirest/flexirest

View on GitHub

Showing 103 of 103 total issues

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

    def self.debug(message)
      if defined?(Rails) && Rails.logger.present?
        Rails.logger.debug(message)
      elsif @logfile
        if @logfile.is_a?(String)
Severity: Minor
Found in lib/flexirest/logger.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 value.nil?
          if block_given?
            @username = block
          else
            value = if @username.nil?
Severity: Minor
Found in lib/flexirest/configuration.rb and 1 other location - About 30 mins to fix
lib/flexirest/configuration.rb on lines 106..124

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

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 value.nil?
          if block_given?
            @password = block
          else
            value = if @password.nil?
Severity: Minor
Found in lib/flexirest/configuration.rb and 1 other location - About 30 mins to fix
lib/flexirest/configuration.rb on lines 77..95

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

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

      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

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

          def _set_attribute(key, value)
            old_value = @dirty_attributes[key.to_sym]
            old_value = @attributes[key.to_sym] unless old_value
            old_value = old_value[0] if old_value and old_value.is_a? Array
            @dirty_attributes[key.to_sym] = [old_value, value] if old_value != value
      Severity: Minor
      Found in lib/flexirest/base_without_validation.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 2 locations. Consider refactoring.
      Open

                    if options[:minimum]
                      @errors[validation[:field_name]] << (validation[:options][:message] || "must be at least #{options[:minimum]} characters long") unless value.to_s.length >= options[:minimum]
      Severity: Minor
      Found in lib/flexirest/validation.rb and 1 other location - About 25 mins to fix
      lib/flexirest/validation.rb on lines 45..46

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

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

            def wrap_root(value=nil)
              if value.nil?
                value = if @wrap_root.nil? && superclass.respond_to?(:wrap_root)
                  superclass.wrap_root
                else
      Severity: Minor
      Found in lib/flexirest/configuration.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 has_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def has_one(key, klass = nil)
              if klass.nil?
                klass = key.to_s.classify.constantize
              end
      
      
      Severity: Minor
      Found in lib/flexirest/associations.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 ignore_root has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def ignore_root(value=nil)
              if value.nil?
                value = if @ignore_root.nil? && superclass.respond_to?(:ignore_root)
                  superclass.ignore_root
                else
      Severity: Minor
      Found in lib/flexirest/configuration.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 proxy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def proxy(value = nil)
              @proxy ||= nil
              value ? @proxy = value : @proxy || nil
      
              if !@proxy.nil?
      Severity: Minor
      Found in lib/flexirest/configuration.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 translate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def translate(result, options = {})
              incoming_content_type = result.headers['Content-Type']
              if result_is_json_or_unspecified?(result)
                result.headers["content-type"] = "application/hal+json"
              end
      Severity: Minor
      Found in lib/flexirest/proxy_base.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

      Severity
      Category
      Status
      Source
      Language