Yogu/site-manager

View on GitHub

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

    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

                    Function Task has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function Task(name, perform) {
                        // capture the callbacks to defer the actual task performance until start() is called
                        Promise.call(this, function(resolve, reject) {
                            this._resolve = function(result) {
                                this.status = 'done';
                    Severity: Minor
                    Found in src/task.js - About 1 hr to fix

                      Function perform has a Cognitive Complexity of 11 (exceeds 5 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

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

                      RestoreTask.prototype.perform = function*() {
                          var site = this.site;
                          var dataPath = fs.join(site.path, 'data');
                      
                          if (!(yield fs.exists(dataPath + '/.git')))
                      Severity: Minor
                      Found in src/tasks/backup.js - About 1 hr to fix

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

                        FetchTask.prototype.perform = function*() {
                            var manager = this.siteManager;
                            
                            this.cd(manager._repoPath);
                            var result = yield this.exec('git fetch origin +refs/heads/*:refs/heads/*');
                        Severity: Minor
                        Found in src/tasks/fetch.js - About 1 hr to fix

                          Function getBackups has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          exports.getBackups = Q.async(function*(site) {
                              if (!(yield fs.exists(site.path + '/data/.git')))
                                  return []; // no data, so no backups
                          
                              var currentBackupRevision = yield exports.getCurrentBackupRevision(site);
                          Severity: Minor
                          Found in src/tasks/backup.js - About 1 hr to fix

                            Function connect has a Cognitive Complexity of 9 (exceeds 5 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 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

                            Avoid deeply nested control flow statements.
                            Open

                                        if (name in object)
                                            dest[name] = extract(object[name], specification);
                            Severity: Major
                            Found in src/objects.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (name.endsWith('[]')) {
                                              name = name.substring(0, name.length - 2);
                                              specification = { '[]': specification };
                                          }
                              Severity: Major
                              Found in src/objects.js - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language