miguelramos/node-media-manager

View on GitHub

Showing 18 of 18 total issues

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

Local.prototype.move = function(from, to, next) {
    /* jshint ignore:start */
    var src  = path.resolve(this.home, path.join(this.home, from)),
        dst  = path.resolve(this.home, path.join(this.home, to)),
        self = this;
Severity: Major
Found in lib/local.js and 1 other location - About 1 day to fix
lib/local.js on lines 393..414

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 213.

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

Local.prototype.link = function(src, dst, next) {
    /* jshint ignore:start */
    var from = path.resolve(this.home, path.join(this.home, src)),
        to   = path.resolve(this.home, path.join(this.home, dst)),
        self = this;
Severity: Major
Found in lib/local.js and 1 other location - About 1 day to fix
lib/local.js on lines 362..383

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 213.

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 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

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

        _mimes: {
            'compressed' : ['zip', 'rar', 'gz', 'tar'],
            'text'       : ['txt', 'md', 'nfo'],
            'image'      : ['jpg', 'jpge', 'png', 'gif', 'bmp', 'svg'],
            'pdf'        : ['pdf'],
Severity: Major
Found in lib/mime.js and 1 other location - About 2 hrs to fix
lib/mime.js on lines 93..103

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 81.

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

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

            module._mimes = {
                'compressed' : ['zip', 'rar', 'gz', 'tar'],
                'text'       : ['txt', 'md', 'nfo'],
                'image'      : ['jpg', 'jpge', 'png', 'gif', 'bmp', 'svg'],
                'pdf'        : ['pdf'],
Severity: Major
Found in lib/mime.js and 1 other location - About 2 hrs to fix
lib/mime.js on lines 27..37

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 81.

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 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

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

    var _rmDir = function(directory) {
        fs.rmdir(directory, errorHandler(function(error, undefined){
            var result = error ? error : directory;

            done.call(self, result, next);
Severity: Minor
Found in lib/local.js and 1 other location - About 55 mins to fix
lib/local.js on lines 279..285

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 53.

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

    var _remove = function() {
        fs.unlink(absolute, errorHandler(function(error, undefined){
            var result = error ? error : absolute;

            done.call(self, result, next);
Severity: Minor
Found in lib/local.js and 1 other location - About 55 mins to fix
lib/local.js on lines 271..277

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 53.

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

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