getlackey/lackey-cms

View on GitHub
modules/cms/server/controllers/page.js

Summary

Maintainability
F
3 days
Test Coverage

Function exports has 363 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    .then((ContentModel, Taxonomy, TaxonomyType, Template, User, Preview) => {

        class PageController {

            static preview(req, res, next) {
Severity: Major
Found in modules/cms/server/controllers/page.js - About 1 day to fix

    File page.js has 378 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* jslint esnext:true, node:true */
    /* globals LACKEY_PATH */
    'use strict';
    /*
        Copyright 2016 Enigma Marketing Services Limited
    Severity: Minor
    Found in modules/cms/server/controllers/page.js - About 5 hrs to fix

      Function print has 117 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  static print(page, fullPath, res, req, preview) {
      
                      let
                          path,
                          user = req.user,
      Severity: Major
      Found in modules/cms/server/controllers/page.js - About 4 hrs to fix

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

            .then((ContentModel, Taxonomy, TaxonomyType, Template, User, Preview) => {
        
                class PageController {
        
                    static preview(req, res, next) {
        Severity: Minor
        Found in modules/cms/server/controllers/page.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 populateContent has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    static populateContent(target, item, req, page) {
                        let includeTaxonomies,
                            excludeTaxonomies;
        
                        return PageController
        Severity: Minor
        Found in modules/cms/server/controllers/page.js - About 1 hr to fix

          Function _mapTaxonomyList has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      static _mapTaxonomyList(list, req, page) {
                          return Promise.all(list.map(taxonomy => {
                                  if (taxonomy.ifNot) {
                                      if (PageController.parse(taxonomy.ifNot, req, page)) {
                                          return null;
          Severity: Minor
          Found in modules/cms/server/controllers/page.js - About 1 hr to fix

            Function capture has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        static capture(req, res, next) {
            
                            let route = req.route.toString().replace(/\..*$/, ''),
                                fullPath = req.protocol + '://' + req.get('host') + route;
            
            
            Severity: Minor
            Found in modules/cms/server/controllers/page.js - About 1 hr to fix

              There are no issues that match your filters.

              Category
              Status