RouteInjector/route-injector

View on GitHub
lib/engine/routeinjector/files/file-injector.js

Summary

Maintainability
F
2 wks
Test Coverage

Function insertFile has 115 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function insertFile(param) {
    return function (req, res) {
        var outDirectory = param.out;
        if (req.files.file != undefined) {
            //ext includes '.'
Severity: Major
Found in lib/engine/routeinjector/files/file-injector.js - About 4 hrs to fix

    Function process has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                        function process() {
    
                            var outFile = path.join(outDirectory, fileName);//path.basename(req.files.file.path));
                            log.debug('File: ', outFile);
    
    Severity: Major
    Found in lib/engine/routeinjector/files/file-injector.js - About 3 hrs to fix

      File file-injector.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var mkdirp = require('mkdirp');
      var fs = require('fs');
      var glob = require('glob');
      var async = require('async');
      var path = require('path');
      Severity: Minor
      Found in lib/engine/routeinjector/files/file-injector.js - About 2 hrs to fix

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

        function getFileNameFromFile(outDirectory, sourceFileName, cb) {
            var fileName = null;
            sourceFileName = sourceFileName.toLowerCase();
        
            if (!fs.existsSync(outDirectory)) {
        Severity: Minor
        Found in lib/engine/routeinjector/files/file-injector.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                                      if (e) {
                                                          log.error(e);
                                                          res.json(e);
                                                          res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                                          return res.end();
          Severity: Major
          Found in lib/engine/routeinjector/files/file-injector.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (i == 0) {
                                        fileName = sourceFileName;
                                    } else {
                                        fileName = addStringBeforeExtension(sourceFileName, '_' + i);
                                    }
            Severity: Major
            Found in lib/engine/routeinjector/files/file-injector.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                                          if (e) {
                                                              log.error(e);
                                                              res.json(e);
                                                              res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                                              return res.end();
              Severity: Major
              Found in lib/engine/routeinjector/files/file-injector.js - About 45 mins to fix

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

                function insertFile(param) {
                    return function (req, res) {
                        var outDirectory = param.out;
                        if (req.files.file != undefined) {
                            //ext includes '.'
                Severity: Major
                Found in lib/engine/routeinjector/files/file-injector.js and 1 other location - About 1 wk to fix
                lib/engine/routeinjector/images/image-injector.js on lines 251..395

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

                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 3 locations. Consider refactoring.
                Open

                function getFileNameFromFile(outDirectory, sourceFileName, cb) {
                    var fileName = null;
                    sourceFileName = sourceFileName.toLowerCase();
                
                    if (!fs.existsSync(outDirectory)) {
                Severity: Major
                Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 1 day to fix
                lib/engine/routeinjector/images/image-injector.js on lines 397..436
                lib/engine/routeinjector/images/new-image-injector.js on lines 354..393

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

                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 3 locations. Consider refactoring.
                Open

                function copyFile(source, target, cb) {
                    var cbCalled = false;
                
                    var rd = fs.createReadStream(source);
                    rd.on("error", function (err) {
                Severity: Major
                Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 6 hrs to fix
                lib/engine/routeinjector/images/image-injector.js on lines 449..471
                lib/engine/routeinjector/images/new-image-injector.js on lines 407..429

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

                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 3 locations. Consider refactoring.
                Open

                function deleteFile(param) {
                    return function (req, res) {
                        var filePath = req.params.path;
                
                        deleteFullPathFile(path.join(param.out, filePath), function (err) {
                Severity: Major
                Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 4 hrs to fix
                lib/engine/routeinjector/images/image-injector.js on lines 490..505
                lib/engine/routeinjector/images/new-image-injector.js on lines 448..463

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

                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 3 locations. Consider refactoring.
                Open

                function deleteFullPathFile(filePath, cb) {
                    fs.exists(filePath, function (exists) {
                        if (exists) {
                            fs.unlink(filePath, function (err) {
                                if (err) {
                Severity: Major
                Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 2 hrs to fix
                lib/engine/routeinjector/images/image-injector.js on lines 473..488
                lib/engine/routeinjector/images/new-image-injector.js on lines 431..446

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

                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 3 locations. Consider refactoring.
                Open

                function addStringBeforeExtension(filename, text) {
                    var ext = getExtension(filename);
                    filename = filename.replace('.' + ext, '');
                    return filename + text + '.' + ext;
                
                Severity: Major
                Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 1 hr to fix
                lib/engine/routeinjector/images/image-injector.js on lines 438..443
                lib/engine/routeinjector/images/new-image-injector.js on lines 395..400

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

                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 3 locations. Consider refactoring.
                Open

                function getExtension(filename) {
                    var ext = path.extname(filename || '').split('.');
                    return ext[ext.length - 1];
                }
                Severity: Major
                Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 50 mins to fix
                lib/engine/routeinjector/images/image-injector.js on lines 444..447
                lib/engine/routeinjector/images/new-image-injector.js on lines 402..405

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

                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

                There are no issues that match your filters.

                Category
                Status