activemodel/lib/active_model/type/helpers/time_value.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method new_time has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

          def new_time(year, mon, mday, hour, min, sec, microsec, offset = nil)
            # Treat 0000-00-00 00:00:00 as nil.
            return if year.nil? || (year == 0 && mon == 0 && mday == 0)

            if offset
Severity: Minor
Found in activemodel/lib/active_model/type/helpers/time_value.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 fast_string_to_time has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

            def fast_string_to_time(string)
              return unless ISO_DATETIME =~ string

              usec = $7.to_i
              usec_len = $7&.length
Severity: Minor
Found in activemodel/lib/active_model/type/helpers/time_value.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 fast_string_to_time has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

            def fast_string_to_time(string)
              return unless ISO_DATETIME.match?(string)

              if is_utc?
                # XXX: Wrapping the Time object with Time.at because Time.new with `in:` in Ruby 3.2.0 used to return an invalid Time object
Severity: Minor
Found in activemodel/lib/active_model/type/helpers/time_value.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 new_time has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

          def new_time(year, mon, mday, hour, min, sec, microsec, offset = nil)
Severity: Major
Found in activemodel/lib/active_model/type/helpers/time_value.rb - About 1 hr to fix

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

            def serialize_cast_value(value)
              value = apply_seconds_precision(value)
    
              if value.acts_like?(:time)
                if is_utc?
    Severity: Minor
    Found in activemodel/lib/active_model/type/helpers/time_value.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

    There are no issues that match your filters.

    Category
    Status