ujh/fountainpencompanion

View on GitHub
app/models/simplifier.rb

Summary

Maintainability
C
1 day
Test Coverage

Method brand_name has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def self.brand_name(name)
    return "24solar" if name =~ /^24\s+solar/i
    if name =~ /^(ancient\s*(charm|song))|(small\s*endowment)/i
      return "ancientsong"
    end
Severity: Minor
Found in app/models/simplifier.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 simplify has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.simplify(name, too_short: false)
    without_no = name.gsub(/^no\s*\.\s*(\d+)/i, '\1')
    return $1 if without_no =~ /^#?(\d+)$/
    without_no = without_no.gsub(/^#(\d+)/, '\1') unless too_short
    without_initials = remove_initials(without_no)
Severity: Minor
Found in app/models/simplifier.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

Avoid too many return statements within this method.
Open

    return "thorntons" if name =~ /^thornton/i
Severity: Major
Found in app/models/simplifier.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return "sbre" if name =~ /^sbre\s*(brown)?$/i
    Severity: Major
    Found in app/models/simplifier.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return "maruzen" if name =~ /^maruzen/i
      Severity: Major
      Found in app/models/simplifier.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return "kwz" if name =~ /^kwz/i
        Severity: Major
        Found in app/models/simplifier.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return "lecritoire" if simplified =~ /^lecritoire/
          Severity: Major
          Found in app/models/simplifier.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return "noodlers" if name =~ /^noodler/i
            Severity: Major
            Found in app/models/simplifier.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return "banmi" if name =~ /^ban\s*mi/i
              Severity: Major
              Found in app/models/simplifier.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return "herbin" if name =~ /herbin/i
                Severity: Major
                Found in app/models/simplifier.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                      return "birminghampens" if name =~ /^birmingham/i
                  Severity: Major
                  Found in app/models/simplifier.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                        return "bril" if name =~ /^bril/i
                    Severity: Major
                    Found in app/models/simplifier.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                          return "pilot" if name =~ /iroshizuku/i
                      Severity: Major
                      Found in app/models/simplifier.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                            return "robertoster" if name =~ /^robert\s*oster/i
                        Severity: Major
                        Found in app/models/simplifier.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                              return "pensalley" if simplified =~ /pensalley/
                          Severity: Major
                          Found in app/models/simplifier.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                return "kyototag" if name =~ /(^tag\s+)|(\s+tag$)|(^tag$)/i
                            Severity: Major
                            Found in app/models/simplifier.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                  return "kobe" if name =~ /^nagasawa/i
                              Severity: Major
                              Found in app/models/simplifier.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                    return "lamy" if name =~ /^lamy/i
                                Severity: Major
                                Found in app/models/simplifier.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                      return "organicsstudio" if simplified =~ /^organics?studios?$/
                                  Severity: Major
                                  Found in app/models/simplifier.rb - About 30 mins to fix

                                    There are no issues that match your filters.

                                    Category
                                    Status