nidhinnambiar/date_to_word

View on GitHub

Showing 5 of 5 total issues

Method to_words has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def self.to_words(value)
    value_length = value.to_s.split('.')
    value_r = value_length[0]
    value_p = value_length[1]
    a = []
Severity: Minor
Found in lib/date_to_word.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 years_to_words has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.years_to_words(y)
    year = y.to_s
    cents = year[0..1].to_s.to_i
    years = year[2..4].to_s.to_i

Severity: Major
Found in lib/date_to_word.rb - About 2 hrs to fix

    Method to_words has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.to_words(value)
        value_length = value.to_s.split('.')
        value_r = value_length[0]
        value_p = value_length[1]
        a = []
    Severity: Minor
    Found in lib/date_to_word.rb - About 1 hr to fix

      Method digits has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.digits
          @digits ||= {
            0 => 'zero',
            1 => 'one',
            2 => 'two',
      Severity: Minor
      Found in lib/date_to_word.rb - About 1 hr to fix

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

          def self.years_to_words(y)
            year = y.to_s
            cents = year[0..1].to_s.to_i
            years = year[2..4].to_s.to_i
        
        
        Severity: Minor
        Found in lib/date_to_word.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

        Severity
        Category
        Status
        Source
        Language