punchcard-cms/punchcard

View on GitHub

Showing 57 of 125 total issues

Function routes has 323 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const routes = application => {
  return new Promise(resolve => {
    const app = application;
    const references = app.get('references');

Severity: Major
Found in lib/routes/content.js - About 1 day to fix

Function routes has 149 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const routes = application => {
  return new Promise(resolve => {
    const app = application;
    const references = app.get('references');

Severity: Major
Found in lib/routes/workflows.js - About 5 hrs to fix

File content.js has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

/*
 * @fileoverview Content system routing
 *
Severity: Minor
Found in lib/routes/content.js - About 4 hrs to fix

Function attributes has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const attributes = (attrs, model, models, query, trx) => {
  const params = _.cloneDeep(query) || {};
  const result = {};
  let references = {};

Severity: Major
Found in lib/api/utils.js - About 4 hrs to fix

Function one has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const one = (req, res, next) => {
  const id = _.get(req.session, 'form.applications.edit.id', null);
  const errors = _.get(req.session, 'form.applications.save.errors', {});
  const values = _.get(req.session, 'form.applications.save.content', {});
  const merged = req.app.get('applications-merged') || {};
Severity: Major
Found in lib/applications/routes.js - About 3 hrs to fix

File utils.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const _ = require('lodash');

const database = require('../database');
Severity: Minor
Found in lib/api/utils.js - About 3 hrs to fix

Function save has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const save = (req, res, next) => {
  const id = _.get(req.session, 'form.users.edit.id', null);
  const referrer = (_.get(req.session, 'referrer') || req.get('Referrer')) || `/${config.users.base}`;
  let merged = req.app.get('users-model') || {};

Severity: Major
Found in lib/users/routes.js - About 3 hrs to fix

Function one has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const one = (req, res, next) => {
  const id = _.get(req.session, 'form.users.edit.id', null);
  const errors = _.get(req.session, 'form.users.save.errors', {});
  const values = _.get(req.session, 'form.users.save.content', {});
  const merged = req.app.get('users-model') || {};
Severity: Major
Found in lib/users/routes.js - About 2 hrs to fix

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

const check = (config) => {
  if (!config.hasOwnProperty('name')) {
    return 'Workflows require a name';
  }

Severity: Minor
Found in lib/workflows/utils.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

Consider simplifying this complex logical expression.
Open

  if ((!req.isAuthenticated || !req.isAuthenticated()) && !req.url.startsWith('/create-admin') && req.url !== config.authentication.login.path && !req.url.startsWith('/css') && !req.url.startsWith('/js') && !req.url.startsWith('/images') && !req.url.startsWith('/favicon') && !req.url.startsWith('/api') && !req.url.startsWith('/tmp') && req.url !== '/robots.txt') {
    res.redirect('/login');
  }
  else {
    // consistent-return turned off because this doesn't return a value
Severity: Critical
Found in lib/init/authenticated.js - About 2 hrs to fix

Function format has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const format = body => {
  const data = {};
  const single = Object.keys(body).filter(input => {
    if ((input === 'sunset-date') || (input === 'sunset-time') || (input === 'sunrise-date') || (input === 'sunrise-time')) {
      data[input] = { 'value': body[input] };
Severity: Major
Found in lib/utils.js - About 2 hrs to fix

Function save has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const save = (req, res) => {
  const id = _.get(req.session, 'form.applications.edit.id', null);
  const referrer = (_.get(req.session, 'referrer') || req.get('Referrer')) || `/${config.applications.base}`;
  const merged = req.app.get('applications-merged') || {};
  let apps = req.app.get('applications-apps') || [];
Severity: Major
Found in lib/applications/routes.js - About 2 hrs to fix

File routes.js has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

/**
 * @fileoverview User routing functions
 *
Severity: Minor
Found in lib/users/routes.js - About 2 hrs to fix

Function fill has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const fill = (types, type, refs, database) => {
  const ct = _.cloneDeep(type);

  if (!ct) {
    return new Promise(resolve => {
Severity: Major
Found in lib/utils.js - About 2 hrs to fix

Function organize has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const organize = (query, custom) => {
  const params = query || {};
  let lookup = custom;

  if (lookup && !Array.isArray(lookup)) {
Severity: Minor
Found in lib/api/utils.js - About 1 hr to fix

Function format has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const format = (content, attrs, models, query, trx) => {
  const params = _.cloneDeep(query) || {};
  let atrs = attrs || [];
  const mods = _.cloneDeep(models) || [];

Severity: Minor
Found in lib/api/utils.js - About 1 hr to fix

Function filehold has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const filehold = (files, val, attributes) => {
  const values = val;

  if (!files || !Array.isArray(files) || !values || typeof values !== 'object' || !attributes || typeof attributes !== 'object') {
    return values;
Severity: Minor
Found in lib/content/utils.js - About 1 hr to fix

Function references has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const references = (types) => {
  const cts = _.cloneDeep(types);
  const refs = [];
  const position = {};

Severity: Minor
Found in lib/utils.js - About 1 hr to fix

Function push has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const push = (revision, apps) => {
  const options = {
    trigger: 'updated',
    apps,
  };
Severity: Minor
Found in lib/schedule/utils.js - About 1 hr to fix

Function check has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const check = (config) => {
  if (!config.hasOwnProperty('name')) {
    return 'Workflows require a name';
  }

Severity: Minor
Found in lib/workflows/utils.js - About 1 hr to fix
Severity
Category
Status
Source
Language