miguelramos/node-media-manager

View on GitHub

Showing 12 of 18 total issues

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

module.exports = (function() {
    /**
     * Object to add properties description to file or folder. Methods
     * to add and list mime types.
     *
Severity: Minor
Found in lib/mime.js - About 3 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 exports has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (function() {
    /**
     * Object to add properties description to file or folder. Methods
     * to add and list mime types.
     *
Severity: Major
Found in lib/mime.js - About 3 hrs to fix

File local.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

/**
 *
 * ----------------------------------------------------------------------------
Severity: Minor
Found in lib/local.js - About 2 hrs to fix

Function merge has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.merge = function merge() {
    var dst = {}, src, p, args = [].splice.call(arguments, 0);

    var toString = Object.prototype.toString;

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

Function open has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Local.prototype.open = function(relative, next) {
    var self      = this,
        directory = path.resolve(this.home, path.join(this.home, relative));

    try {
Severity: Minor
Found in lib/local.js - About 1 hr to fix

Function _stat has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _stat: function(filepath) {

            var result = {
                name    : path.basename(filepath),
                path    : filepath,
Severity: Minor
Found in lib/mime.js - About 1 hr to fix

Function remove has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Local.prototype.remove = function(relative, next) {
    var absolute = path.resolve(this.home, path.join(this.home, relative)),
        self     = this;

    try {
Severity: Minor
Found in lib/local.js - About 1 hr to fix

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

Local.prototype.copy = function(src, dst, next) {
    var from = path.resolve(this.home, path.join(this.home, src)),
        to   = path.resolve(this.home, path.join(this.home, dst)),
        self = this;

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

Function add has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Local.prototype.add = function(src, to, next) {
    var self     = this,
        basename = path.basename(src, path.extname(src)),
        filename = S(basename).slugify().s;

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

Avoid deeply nested control flow statements.
Open

                    if (toString.call(src[p]) === '[object Object]') {
                        dst[p] = merge(dst[p] || {}, src[p]);
                    } else {
                        dst[p] = src[p];
                    }
Severity: Major
Found in lib/utils.js - About 45 mins to fix

Function open has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

Local.prototype.open = function(relative, next) {
    var self      = this,
        directory = path.resolve(this.home, path.join(this.home, relative));

    try {
Severity: Minor
Found in lib/local.js - About 45 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

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

Local.prototype.remove = function(relative, next) {
    var absolute = path.resolve(this.home, path.join(this.home, relative)),
        self     = this;

    try {
Severity: Minor
Found in lib/local.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