iwan/time_array

View on GitHub

Showing 6 of 6 total issues

Class TimeArray has 44 methods (exceeds 20 allowed). Consider refactoring.
Open

  class TimeArray
    attr_reader :start_time, :v, :unit

    # Used by each method
    class TimeAndValue
Severity: Minor
Found in lib/time_array/time_array.rb - About 6 hrs to fix

    File time_array.rb has 327 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'active_support/core_ext/time/zones'
    require 'active_support/core_ext/time/calculations'
    require 'active_support/core_ext/numeric/time'
    require 'active_support/core_ext/hash'
    
    
    Severity: Minor
    Found in lib/time_array/time_array.rb - About 3 hrs to fix

      Method greatest_unit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def greatest_unit
            v = @v.first
            unit = Unit::YEAR # Unit::ETERNITY
            each_with_time do |el|
                      
      Severity: Minor
      Found in lib/time_array/time_array.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 read_start_time has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def read_start_time(start_time)
            if start_time.is_a?(String)
              start_time.gsub!("/", "-")
              start_time = "20#{r[0]}-01-01" if r = start_time.match(/^\d{2}$/) # "yy"
              start_time = "#{r[0]}-01-01"   if r = start_time.match(/^\d{4}$/) # "yyyy"
      Severity: Minor
      Found in lib/time_array/time_array.rb - About 55 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 if_zero_then has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def if_zero_then(other_array)
            return self if other_array.nil?
            raise NilVectorError if @v.nil? || (other_array.is_a?(TimeArray) && other_array.v.nil?)
      
            c = self.clone
      Severity: Minor
      Found in lib/time_array/time_array.rb - About 55 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 oper has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def oper(other_array, op)
            return self if other_array.nil?
            raise NilVectorError if @v.nil? || (other_array.is_a?(TimeArray) && other_array.v.nil?)
      
            c = self.clone
      Severity: Minor
      Found in lib/time_array/time_array.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

      Severity
      Category
      Status
      Source
      Language