balinterdi/i15r

View on GitHub

Showing 4 of 4 total issues

Method transform has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def transform(match_data, match, line, translation_key)
        return line if line.match /\bt\(/
        leading_whitespace = line[/^(\s+)/, 1]
        no_leading_whitespace = if leading_whitespace
          line[leading_whitespace.size..-1]
Severity: Minor
Found in lib/i15r/pattern_matcher.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 run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def run(text)
      lines = text.split("\n")
      new_lines = lines.map do |line|
        new_line = line
        if line !~ /[[:alpha:]]/
Severity: Minor
Found in lib/i15r/pattern_matcher.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 transform has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def transform(match_data, match, line, translation_key)
        return line if line.match /\bt\(/
        leading_whitespace = line[/^(\s+)/, 1]
        no_leading_whitespace = if leading_whitespace
          line[leading_whitespace.size..-1]
Severity: Minor
Found in lib/i15r/pattern_matcher.rb - About 1 hr to fix

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

            def i18n_string(key, original)
              @locale_creator.add(key, original)
    
              if @add_default
                if original.to_s[0] == ':'
    Severity: Minor
    Found in lib/i15r/pattern_matcher.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