rubinius/rubinius

View on GitHub
core/time.rb

Summary

Maintainability
F
3 days
Test Coverage

Class Time has 54 methods (exceeds 20 allowed). Consider refactoring.
Open

class Time
  include Comparable

  def self.now
    Rubinius.primitive :time_s_now
Severity: Major
Found in core/time.rb - About 7 hrs to fix

    File time.rb has 397 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Time
      include Comparable
    
      def self.now
        Rubinius.primitive :time_s_now
    Severity: Minor
    Found in core/time.rb - About 5 hrs to fix

      Method compose has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.compose(offset, p1, p2=nil, p3=nil, p4=nil, p5=nil, p6=nil, p7=nil,
                         yday=undefined, is_dst=undefined, tz=undefined)
          if undefined.equal?(tz)
            unless undefined.equal?(is_dst)
              raise ArgumentError, "wrong number of arguments (9 for 1..8)"
      Severity: Minor
      Found in core/time.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 compose has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.compose(offset, p1, p2=nil, p3=nil, p4=nil, p5=nil, p6=nil, p7=nil,
                         yday=undefined, is_dst=undefined, tz=undefined)
          if undefined.equal?(tz)
            unless undefined.equal?(is_dst)
              raise ArgumentError, "wrong number of arguments (9 for 1..8)"
      Severity: Major
      Found in core/time.rb - About 2 hrs to fix

        Method from_array has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, utc_offset)
            Rubinius.primitive :time_s_from_array
        
            if sec.kind_of?(String)
              sec = sec.to_i
        Severity: Minor
        Found in core/time.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 compose has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def self.compose(offset, p1, p2=nil, p3=nil, p4=nil, p5=nil, p6=nil, p7=nil,
                           yday=undefined, is_dst=undefined, tz=undefined)
        Severity: Major
        Found in core/time.rb - About 1 hr to fix

          Method from_array has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def self.from_array(sec, min, hour, mday, month, year, nsec, is_dst, from_gmt, utc_offset)
          Severity: Major
          Found in core/time.rb - About 1 hr to fix

            Method <=> has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def <=>(other)
                if other.kind_of? Time
                  (seconds <=> other.seconds).nonzero? or (nsec <=> other.nsec)
                else
                  r = (other <=> self)
            Severity: Minor
            Found in core/time.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 at has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.at(sec, usec=undefined)
                if undefined.equal?(usec)
                  if sec.kind_of?(Time)
                    return duplicate(sec)
                  elsif sec.kind_of?(Integer)
            Severity: Minor
            Found in core/time.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 new has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def self.new(year=undefined, month=nil, day=nil, hour=nil, minute=nil, second=nil, utc_offset=nil)
            Severity: Major
            Found in core/time.rb - About 50 mins to fix

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

                def self._load(data)
                  raise TypeError, 'marshaled time format differ' unless data.bytesize == 8
              
                  major, minor = data.unpack 'VV'
              
              
              Severity: Minor
              Found in core/time.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