punchcard-cms/punchcard

View on GitHub

Showing 125 of 125 total issues

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        values[filer.attr] = {
          [filer.input]: {
            value: {
              type: filedata.mimetype,
              original: filedata.originalname,
Severity: Major
Found in lib/content/utils.js and 1 other location - About 1 hr to fix
lib/content/utils.js on lines 155..163

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            values[filer.attr].push({
              [filer.input]: {
                value: {
                  type: repeater.mimetype,
                  original: repeater.originalname,
Severity: Major
Found in lib/content/utils.js and 1 other location - About 1 hr to fix
lib/content/utils.js on lines 134..142

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      return database
        .select('*')
        .from(`content-type--${req.content.type.id}`)
        .where('revision', req.params.revision)
        .orderBy('revision', 'DESC').then(rws => {
Severity: Major
Found in lib/routes/content.js and 1 other location - About 1 hr to fix
lib/routes/content.js on lines 120..147

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      return database
        .select('*')
        .from(`content-type--${req.content.type.id}`)
        .where('id', req.params.id)
        .orderBy('revision', 'DESC').then(rws => {
Severity: Major
Found in lib/routes/content.js and 1 other location - About 1 hr to fix
lib/routes/content.js on lines 158..184

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

const fileinputs = attributes => {
  const attrs = attributes;

  if (!attrs || !Array.isArray(attrs)) {
    return [];
Severity: Minor
Found in lib/content/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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          if (latest.publishable && latest.approval === 1) {
            return schedule(latest, req.content.type, req.app.get('applications-apps')).then(() => {
              return latest;
            });
          }
Severity: Major
Found in lib/routes/content.js and 1 other location - About 1 hr to fix
lib/routes/workflows.js on lines 192..196

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 68.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

              if (latest.publishable && latest.approval === 0) {
                return schedule(latest, req.content.type, req.app.get('applications-apps')).then(() => {
                  return latest;
                });
              }
Severity: Major
Found in lib/routes/workflows.js and 1 other location - About 1 hr to fix
lib/routes/content.js on lines 438..442

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 68.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

const routes = application => {
  const app = application;

  const types = api.types(app);

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

Function organize has a Cognitive Complexity of 13 (exceeds 5 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

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 load has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const load = (wfpath) => {
  const workflows = [];
  const ids = [];
  let workflowsPath = path.join(process.cwd(), 'workflows');

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      const filedata = files.find(file => {
        return (file.originalname !== '' && file.fieldname === `${finput.attr}--${finput.input}`);
      });
Severity: Major
Found in lib/content/utils.js and 1 other location - About 1 hr to fix
lib/content/utils.js on lines 129..131

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      const filedata = files.find(file => {
        return (file.originalname !== '' && file.fieldname === `${filer.attr}--${filer.input}`);
      });
Severity: Major
Found in lib/content/utils.js and 1 other location - About 1 hr to fix
lib/content/utils.js on lines 198..200

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language