Sage/class_kit

View on GitHub

Showing 9 of 10 total issues

Method parse has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(type:, value:)
      if type == Time
        if value.is_a?(Time)
          value
        elsif value.is_a?(Integer) || value.is_a?(Float) || value.is_a?(BigDecimal)
Severity: Minor
Found in lib/class_kit/value_helper.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 from_hash has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def from_hash(hash:, klass:, use_alias: false)
      validate_class_kit(klass)

      return hash.map { |i| from_hash(hash: i, klass: klass, use_alias: use_alias) } if hash.is_a?(Array)

Severity: Minor
Found in lib/class_kit/helper.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 to_hash has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def to_hash(object, use_alias = false)
      return object.map { |i| to_hash(i, use_alias) } if object.is_a?(Array)

      validate_class_kit(object.class)

Severity: Minor
Found in lib/class_kit/helper.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 attr_accessor_type has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def attr_accessor_type(
    name,
    type: nil,
    collection_type: nil,
    allow_nil: true,
Severity: Minor
Found in lib/class_kit/class_methods.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 parse has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse(type:, value:)
      if type == Time
        if value.is_a?(Time)
          value
        elsif value.is_a?(Integer) || value.is_a?(Float) || value.is_a?(BigDecimal)
Severity: Major
Found in lib/class_kit/value_helper.rb - About 2 hrs to fix

    Method attr_accessor_type has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def attr_accessor_type(
        name,
        type: nil,
        collection_type: nil,
        allow_nil: true,
    Severity: Minor
    Found in lib/class_kit/class_methods.rb - About 1 hr to fix

      Method from_hash has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def from_hash(hash:, klass:, use_alias: false)
            validate_class_kit(klass)
      
            return hash.map { |i| from_hash(hash: i, klass: klass, use_alias: use_alias) } if hash.is_a?(Array)
      
      
      Severity: Minor
      Found in lib/class_kit/helper.rb - About 1 hr to fix

        Method to_hash has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def to_hash(object, use_alias = false)
              return object.map { |i| to_hash(i, use_alias) } if object.is_a?(Array)
        
              validate_class_kit(object.class)
        
        
        Severity: Minor
        Found in lib/class_kit/helper.rb - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                  if value == true || value == false
                    value
                  elsif(/(true|t|yes|y|1)$/i === value.to_s.downcase)
                    true
                  elsif (/(false|f|no|n|0)$/i === value.to_s.downcase)
          Severity: Major
          Found in lib/class_kit/value_helper.rb - About 45 mins to fix
            Severity
            Category
            Status
            Source
            Language