Yogu/site-manager

View on GitHub

Showing 48 of 48 total issues

Function start has 231 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.start = function(port, dir) {
    var app = express();
    var server = http.createServer(app);
    app.use(express.static(__dirname+'/../public'));
    app.use(require('express-promise')());
Severity: Major
Found in src/server.js - About 1 day to fix

    Function extract has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

    function extract(object, properties) {
        var dest = {};
        
        if (typeof properties == 'string')
            properties = [properties];
    Severity: Minor
    Found in src/objects.js - About 1 day 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

        try {
            if (this.site.stagingOf) {
                this.doLog('This is a staging site, resetting to ' + this.site.stagingOf + '...');
                // skip the backup pre-restore because we already made a backup
                yield this.runNested(site.resetStagingTask( { backup: false }));
    Severity: Major
    Found in src/tasks/upgradeSite.js and 1 other location - About 7 hrs to fix
    src/tasks/upgradeToRevision.js on lines 44..71

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

    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

        try {
            if (needToMerge) {
                this.doLog('Merging new revision...');
                yield this.exec('git merge ' + this.revision);
            } else {
    Severity: Major
    Found in src/tasks/upgradeToRevision.js and 1 other location - About 7 hrs to fix
    src/tasks/upgradeSite.js on lines 29..65

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

    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

        app.get('/api/sites/:site/backups/:revision', function(req, res) {
            controller.getSite(req.params.site)
                .then(function(site) {
                    return site.getBackup(req.params.revision);
                })
    Severity: Major
    Found in src/server.js and 1 other location - About 5 hrs to fix
    src/server.js on lines 239..251

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

    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

        app.get('/api/sites/:site/tasks/:id', function(req, res) {
            controller.getSite(req.params.site)
            .then(function(site) {
                return site.getTask(req.params.id);
            })
    Severity: Major
    Found in src/server.js and 1 other location - About 5 hrs to fix
    src/server.js on lines 188..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 145.

    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

        app.post('/api/sites/:site/reset-staging', function(req, res) {
            controller.getSite(req.params.site)
            .then(function(site) {
                site.schedule(site.resetStagingTask());
                res.send(202 /* accepted */);
    Severity: Major
    Found in src/server.js and 2 other locations - About 4 hrs to fix
    src/server.js on lines 95..105
    src/server.js on lines 138..148

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

    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

        app.post('/api/sites/:site/reset', function(req, res) {
            controller.getSite(req.params.site)
            .then(function(site) {
                site.schedule(site.resetTask());
                res.send(202 /* accepted */);
    Severity: Major
    Found in src/server.js and 2 other locations - About 4 hrs to fix
    src/server.js on lines 95..105
    src/server.js on lines 150..160

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

    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

        app.post('/api/sites/:site/upgrade', function(req, res) {
            controller.getSite(req.params.site)
            .then(function(site) {
                site.schedule(site.upgradeTask());
                res.send(202 /* accepted */);
    Severity: Major
    Found in src/server.js and 2 other locations - About 4 hrs to fix
    src/server.js on lines 138..148
    src/server.js on lines 150..160

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

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

    AddSiteTask.prototype.perform = function*() {
        var manager = this.siteManager;
        var siteName = this.siteName;
    
        yield this.runNestedQuietly(manager.loadTask(false));
    Severity: Major
    Found in src/tasks/addSite.js - About 2 hrs to fix

      Function perform has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      LoadSiteManagerTask.prototype.perform = function*() {
          var manager = this.siteManager;
          this.doLog('Loading config.yaml...');
          var data = yield fs.read(manager.path + '/config.yaml');
          var config = yaml.safeLoad(data);
      Severity: Minor
      Found in src/tasks/loadSiteManager.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 perform has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      LoadSiteManagerTask.prototype.perform = function*() {
          var manager = this.siteManager;
          this.doLog('Loading config.yaml...');
          var data = yield fs.read(manager.path + '/config.yaml');
          var config = yaml.safeLoad(data);
      Severity: Major
      Found in src/tasks/loadSiteManager.js - About 2 hrs to fix

        Function extract has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function extract(object, properties) {
            var dest = {};
            
            if (typeof properties == 'string')
                properties = [properties];
        Severity: Major
        Found in src/objects.js - About 2 hrs to fix

          Function perform has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          UpgradeToRevisionTask.prototype.perform = function*() {
              var site = this.site;
              this.cd(this.site.path);
          
              yield this.exec('git fetch');
          Severity: Minor
          Found in src/tasks/upgradeToRevision.js - About 1 hr to fix

            Function connect has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.connect = Q.async(function*(options) {
                options = Object.create(options);
                options.multipleStatements = true;
                
                var connection = mysql.createConnection(options);
            Severity: Minor
            Found in src/databases/mysql.js - About 1 hr to fix

              Function perform has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              UpgradeSiteTask.prototype.perform = function*() {
                  var site = this.site;
                  this.cd(this.site.path);
              
                  this.doLog('Checking if site can be upgraded...');
              Severity: Minor
              Found in src/tasks/upgradeSite.js - About 1 hr to fix

                Function connect has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.connect = Q.async(function*(options) {
                    if (typeof options.path != 'string')
                        throw new Error("sqlite database requires path option to be string");
                    
                    var connection = yield Q.nfcall(sqlite.open, options.path, {});
                Severity: Minor
                Found in src/databases/sqlite.js - About 1 hr to fix

                  Function perform has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  UpgradeToRevisionTask.prototype.perform = function*() {
                      var site = this.site;
                      this.cd(this.site.path);
                  
                      yield this.exec('git fetch');
                  Severity: Minor
                  Found in src/tasks/upgradeToRevision.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 perform has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  LoadSiteTask.prototype.perform = function*() {
                      try {
                          this.cd(this.site.path);
                  
                          yield this.exec("git fetch");
                  Severity: Minor
                  Found in src/tasks/loadSite.js - About 1 hr to fix

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

                        for (var i = 0; i <  this.sites.length; i++) {
                            if (this.sites[i].name == siteName)
                                return this.sites[i];
                        }
                    Severity: Major
                    Found in src/siteManager.js and 1 other location - About 1 hr to fix
                    src/persistentTaskContext.js on lines 103..106

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

                    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