thenickcox/syllabize

View on GitHub

Showing 3 of 3 total issues

Class Counter has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Counter
    attr_accessor :str, :exceptions_file

    def initialize(str)
      @str = strip_punctuation(str)
Severity: Minor
Found in lib/syllabize.rb - About 3 hrs to fix

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

        def count_syllables
          @str = str.to_i.to_words if is_int_in_string_form?
          return break_into_words  if str.split(' ').length > 1
          return handle_exceptions if exceptions.keys.include?(str)
          count_suffixes if str.scan(SUFFIXES).any?
    Severity: Minor
    Found in lib/syllabize.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

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

        def is_int_in_string_form?
          str_as_int = str.to_i
          if str_as_int.zero?
            return str == '0' ? true : false
          end
    Severity: Minor
    Found in lib/syllabize.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