Nijikokun/mithril-router

View on GitHub

Showing 7 of 7 total issues

Function MithrilRouter has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
Open

})(function MithrilRouter (m) {
  // Mithril is already patched, exit to avoid infinite recursion
  if (m._route) {
    return m
  }
Severity: Minor
Found in mithril.router.js - About 1 day 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

Function MithrilRouter has 172 lines of code (exceeds 25 allowed). Consider refactoring.
Open

})(function MithrilRouter (m) {
  // Mithril is already patched, exit to avoid infinite recursion
  if (m._route) {
    return m
  }
Severity: Major
Found in mithril.router.js - About 6 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        if (arguments.length === 2 && typeof arguments[0] === 'string' && (typeof arguments[1] === 'object' || typeof arguments[1] === 'boolean' || typeof arguments[1] === 'undefined')) {
          return m._route(m.routes[arguments[0]] || arguments[0], arguments[1])
        }
    Severity: Major
    Found in mithril.router.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

          if (arguments.length === 3 && typeof arguments[0] === 'string' && (typeof arguments[1] === 'object' || typeof arguments[1] === 'undefined') && typeof arguments[2] === 'boolean') {
            return m._route(m.routes[arguments[0]] || arguments[0], arguments[1], arguments[2])
          }
      Severity: Major
      Found in mithril.router.js - About 40 mins to fix

        Avoid too many return statements within this function.
        Open

              return m.route._config(arguments[0], arguments[1])
        Severity: Major
        Found in mithril.router.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return m.route._config(arguments[0], arguments[2], arguments[1])
          Severity: Major
          Found in mithril.router.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return m._route.call(this, arguments[0], arguments[1], arguments[2], arguments[3])
            Severity: Major
            Found in mithril.router.js - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language