rpanachi/core_ext

View on GitHub
lib/core_ext/time_zone.rb

Summary

Maintainability
C
1 day
Test Coverage

Class TimeZone has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class TimeZone
    # Keys are Rails TimeZone names, values are TZInfo identifiers.
    MAPPING = {
      "International Date Line West" => "Pacific/Midway",
      "Midway Island"                => "Pacific/Midway",
Severity: Minor
Found in lib/core_ext/time_zone.rb - About 3 hrs to fix

    File time_zone.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'tzinfo'
    require 'core_ext/object/blank'
    require 'core_ext/object/try'
    require 'concurrent/map'
    
    
    Severity: Minor
    Found in lib/core_ext/time_zone.rb - About 3 hrs to fix

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

          def utc_offset
            if @utc_offset
              @utc_offset
            else
              @current_period ||= tzinfo.current_period if tzinfo
      Severity: Minor
      Found in lib/core_ext/time_zone.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

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

            def parts_to_time(parts, now)
              return if parts.empty?
      
              time = Time.new(
                parts.fetch(:year, now.year),
      Severity: Minor
      Found in lib/core_ext/time_zone.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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def [](arg)
              case arg
                when String
                begin
                  @lazy_zones_map[arg] ||= create(arg)
      Severity: Minor
      Found in lib/core_ext/time_zone.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