lib/volt/utils/time_opal_patch.rb

Summary

Maintainability
F
3 days
Test Coverage

File time_opal_patch.rb has 590 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'corelib/comparable'

class Time 
  include Comparable

Severity: Major
Found in lib/volt/utils/time_opal_patch.rb - About 1 day to fix

    Method strftime has 184 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def strftime(format)
        %x{
          return format.replace(/%([\-_#^0]*:{0,2})(\d+)?([EO]*)(.)/g, function(full, flags, width, _, conv) {
            var result = "",
                zero   = flags.indexOf('0') !== -1,
    Severity: Major
    Found in lib/volt/utils/time_opal_patch.rb - About 7 hrs to fix

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

      class Time 
        include Comparable
      
        %x{
          var days_of_week = #{%w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday]},
      Severity: Minor
      Found in lib/volt/utils/time_opal_patch.rb - About 5 hrs to fix

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

          def cweek_cyear
            jan01 = Time.new(self.year, 1, 1)
            jan01_wday = jan01.wday
            first_monday = 0
            year = self.year
        Severity: Minor
        Found in lib/volt/utils/time_opal_patch.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 local has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def self.local(year, month = nil, day = nil, hour = nil, min = nil, sec = nil, millisecond = nil)
        Severity: Major
        Found in lib/volt/utils/time_opal_patch.rb - About 50 mins to fix

          Method gm has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def self.gm(year, month = nil, day = nil, hour = nil, min = nil, sec = nil, millisecond = nil)
          Severity: Major
          Found in lib/volt/utils/time_opal_patch.rb - About 50 mins to fix

            Method new has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def self.new(year = undefined, month = nil, day = nil, hour = nil, min = nil, sec = nil, utc_offset = nil)
            Severity: Major
            Found in lib/volt/utils/time_opal_patch.rb - About 50 mins to fix

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

                def strftime(format)
                  %x{
                    return format.replace(/%([\-_#^0]*:{0,2})(\d+)?([EO]*)(.)/g, function(full, flags, width, _, conv) {
                      var result = "",
                          zero   = flags.indexOf('0') !== -1,
              Severity: Minor
              Found in lib/volt/utils/time_opal_patch.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 <=> has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def <=>(other)
                  if Time === other
                    to_f <=> other.to_f
                  else
                    r = other <=> self
              Severity: Minor
              Found in lib/volt/utils/time_opal_patch.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