JamesonNetworks/Nirodha

View on GitHub

Showing 42 of 42 total issues

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

            monitor.on("removed", function (f) {
                logger.log('Removed file ' + f);
                if(!(f.indexOf('deploy/') > -1)) {
                    wm.projectFileChangeEventHandler(f, callback);
                }
Severity: Major
Found in bin/watch.js and 2 other locations - About 1 hr to fix
bin/watch.js on lines 16..21
bin/watch.js on lines 22..27

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

        MinifyFile: function(cb) {
            var include;
            var includeTitle;

            var inPath;
Severity: Minor
Found in bin/view.js - About 1 hr to fix

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

                if(type === 'js') {
                    res.writeHead(200, {
                        'Content-Type': 'application/javascript',
                        'cache-control':'no-cache'
                    });
    Severity: Major
    Found in bin/libraryManager.js and 1 other location - About 1 hr to fix
    bin/libraryManager.js on lines 168..177

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

    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

                else {
                    res.writeHead(200, {
                        'Content-Type': 'text/css',
                        'cache-control':'no-cache'
                    });
    Severity: Major
    Found in bin/libraryManager.js and 1 other location - About 1 hr to fix
    bin/libraryManager.js on lines 158..167

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

    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 12 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function (args, settings, callback) {
        logger.debug('Entering create...', 6);
        logger.debug('Args: ' + JSON.stringify(args));
        logger.debug('Settings: ' + JSON.stringify(settings));
    
    
    Severity: Minor
    Found in bin/create.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 serveLibrary has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    LibraryManager.prototype.serveLibrary = function(uri, res, callback) {
        var type = uri.indexOf('js') > 0 ? 'js' : 'css';
        getLibraryContents(uri, function(pageText, found) {
            if(found) {
                if(type === 'js') {
    Severity: Minor
    Found in bin/libraryManager.js - About 1 hr to fix

      Function exports has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function (args, settings, callback) {
          logger.debug('Entering create...', 6);
          logger.debug('Args: ' + JSON.stringify(args));
          logger.debug('Settings: ' + JSON.stringify(settings));
      
      
      Severity: Minor
      Found in bin/create.js - About 1 hr to fix

        Function walkSync has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function walkSync (start, callback) {
          if(fs.existsSync(start)) {
            var stat = fs.statSync(start);
        
            if (stat.isDirectory()) {
        Severity: Minor
        Found in bin/utilities.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 exports has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function () {
        
            var wm = require('./watchManager.js');
        
            var callback = function() {
        Severity: Minor
        Found in bin/watch.js - About 1 hr to fix

          Function copyStaticFiles has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          View.prototype.copyStaticFiles = function(callback) {
              var staticDirectory = 'custom/static';
              utils.walkSync(staticDirectory, function(dir, directories, fileNames) {
                  logger.debug('Directory: ' + dir);
                  logger.debug('FileNames: ' + JSON.stringify(fileNames));
          Severity: Minor
          Found in bin/view.js - About 1 hr to fix

            Function getLibraryContents has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            var getLibraryContents = function(uri, callback) {
                logger.debug('Entering getLibraryContents...');
                logger.debug(JSON.stringify(Libraries));
                if(typeof(Libraries) === 'undefined') {
                    throw new Error('No libraries defined, did you call LibraryManager.init first?');
            Severity: Minor
            Found in bin/libraryManager.js - About 55 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

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

                    var jsincludes = (script.js.start + '/js/' + this.name  + '-' + title + '.js' + script.js.end);
            Severity: Minor
            Found in bin/view.js and 1 other location - About 50 mins to fix
            bin/view.js on lines 303..303

            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

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

                    var cssincludes = (script.css.start + '/css/' + this.name + '-' + title + '.css' + script.css.end);
            Severity: Minor
            Found in bin/view.js and 1 other location - About 50 mins to fix
            bin/view.js on lines 302..302

            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

            Avoid deeply nested control flow statements.
            Open

                                    for(var l = 0; l < libraries[i][k].fileNames.length; l++) {
                                        if(typeof(libraryContainer[libraries[i][k].fileNames[l]]) === 'undefined') {
                                            libraryContainer[libraries[i][k].fileNames[l]] = {};
                                            libraryContainer[libraries[i][k].fileNames[l]].dir = libraries[i][k].dir;                                
                                        }
            Severity: Major
            Found in bin/libraryManager.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              if(typeof(callback) !== 'undefined') {
                                  callback(null, testing.nirodhaManager.notfound);
                              }
              Severity: Major
              Found in bin/server.js - About 45 mins to fix

                Function handleRequest has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function handleRequest (req, res, rootDirectory, htmlFiles, callback) {
                Severity: Minor
                Found in bin/server.js - About 35 mins to fix

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

                  Util.prototype.hasDuplicateLibraries = function(libraries) {
                    logger.debug('Libraries is: ' + JSON.stringify(libraries));
                    var librariesByName = [];
                    for(var i = 0; i < libraries.length; i++) {
                      for(var k = 0; k < libraries[i].length; k++) {
                  Severity: Minor
                  Found in bin/utilities.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

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

                  function generateIncludes(libobject, type) {
                      var files = libobject.libs[type];
                  
                      logger.log('Generating includes...', 7);
                      logger.log('Library lengths: ' + files.length, 7);
                  Severity: Minor
                  Found in bin/view.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

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

                  function getLibraries(cwd, type, include, callback) {
                      
                      process.chdir(cwd);
                      logger.debug('Entering loop to add ' + type + ' libraries');
                      var files = include.libs[type];
                  Severity: Minor
                  Found in bin/view.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

                  Function getDuplicateLibraries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Util.prototype.getDuplicateLibraries = function(libraries) {
                    var librariesByName = [];
                    for(var i = 0; i < libraries.length; i++) {
                      for(var k = 0; k < libraries[i].length; k++) {
                        logger.debug('Libraries in loop: ' + JSON.stringify(libraries[i][k].fileNames));
                  Severity: Minor
                  Found in bin/utilities.js - About 25 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