infertux/ordinalize_full

View on GitHub

Showing 7 of 7 total issues

Method number_to_word has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def number_to_word(number)
    if number.zero?
      I18n.t("long_form.simple.ones.n_0", throw: true)
    elsif number < 20
      I18n.t("long_form.simple.ones.n_#{number}", throw: true)
Severity: Minor
Found in lib/ordinalize_full.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 ordinalize_in_full has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def ordinalize_in_full(gender: :masculine, plurality: :singular)
    case I18n.locale
    when :fr
      value = I18n.t("ordinalize_full.n_#{self}_#{gender}", throw: false, default: "")
      value = I18n.t("ordinalize_full.n_#{self}", throw: true) if value.empty?
Severity: Minor
Found in lib/ordinalize_full.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 ordinalize_in_short has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def ordinalize_in_short(gender: :masculine, plurality: :singular)
    abs_number = to_i.abs
    suffix = \
      case I18n.locale
      when :en
Severity: Minor
Found in lib/ordinalize_full.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 ordinalize_in_short has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def ordinalize_in_short(gender: :masculine, plurality: :singular)
    abs_number = to_i.abs
    suffix = \
      case I18n.locale
      when :en
Severity: Minor
Found in lib/ordinalize_full.rb - About 1 hr to fix

    Method number_to_word has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def number_to_word(number)
        if number.zero?
          I18n.t("long_form.simple.ones.n_0", throw: true)
        elsif number < 20
          I18n.t("long_form.simple.ones.n_#{number}", throw: true)
    Severity: Minor
    Found in lib/ordinalize_full.rb - About 1 hr to fix

      Method ordinalize_in_full has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def ordinalize_in_full(gender: :masculine, plurality: :singular)
          case I18n.locale
          when :fr
            value = I18n.t("ordinalize_full.n_#{self}_#{gender}", throw: false, default: "")
            value = I18n.t("ordinalize_full.n_#{self}", throw: true) if value.empty?
      Severity: Minor
      Found in lib/ordinalize_full.rb - About 1 hr to fix

        Method number_to_ordinal_word has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def number_to_ordinal_word(number)
            if number.zero?
              I18n.t("long_form.ordinal.ones.n_0", throw: true)
            elsif number < 20
              I18n.t("long_form.ordinal.ones.n_#{number}", throw: true)
        Severity: Minor
        Found in lib/ordinalize_full.rb - About 45 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