trailsjs/trailpack-markdown-doc

View on GitHub

Showing 4 of 7 total issues

Function addRoutes has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  addRoutes: app => {
    const prefix = _.get(app.config, 'markdowndoc.prefix') || _.get(app.config, 'footprints.prefix')
    const routerUtil = app.packs.router.util

    // Initiate the bundler
Severity: Major
Found in lib/markdowndoc.js - About 2 hrs to fix

    Function routesMaker has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.routesMaker = function(app, bundle, prefix, sitemap) {
    
      if (!app) {
        throw 'Please include trails app'
      }
    Severity: Minor
    Found in lib/routesmaker.js - 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

    Function routesMaker has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports.routesMaker = function(app, bundle, prefix, sitemap) {
    
      if (!app) {
        throw 'Please include trails app'
      }
    Severity: Major
    Found in lib/routesmaker.js - About 2 hrs to fix

      Function handleRecursive has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function handleRecursive(docs, pwd) {
        if (typeof docs == 'string' || imageRegex.test(pwd)) {
          return []
        }
        const routes = _.map(docs, (doc, title) => {
      Severity: Minor
      Found in lib/sitemapper.js - About 35 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