flexirest/flexirest

View on GitHub
lib/flexirest/base_without_validation.rb

Summary

Maintainability
C
1 day
Test Coverage

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

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 method_missing has 34 lines of code (exceeds 25 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 1 hr to fix

      Method inspect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def inspect
            inspection = if @attributes.any?
                           @attributes.collect { |key, value|
                             "#{key}: #{value_for_inspect(value)}"
                           }.compact.join(", ")
      Severity: Minor
      Found in lib/flexirest/base_without_validation.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

      Avoid deeply nested control flow statements.
      Open

                    raise ValidationFailedException.new if respond_to?(:valid?) && !valid?
      Severity: Major
      Found in lib/flexirest/base_without_validation.rb - About 45 mins to fix

        Method value_for_inspect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def value_for_inspect(value)
              if value.is_a?(String) && value.length > 50
                "#{value[0..50]}...".inspect
              elsif value.is_a?(Date) || value.is_a?(Time)
                %("#{value.respond_to?(:to_fs) ? value.to_fs(:db) : value.to_s(:db)}")
        Severity: Minor
        Found in lib/flexirest/base_without_validation.rb - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        There are no issues that match your filters.

        Category
        Status