Yogu/site-manager

View on GitHub

Showing 48 of 48 total issues

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

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

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

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

    if (config.logRoot)
        manager._logRoot = path.resolve(manager.path, config.logRoot);
    else
        manager._logRoot = path.resolve(manager.path, 'log');
Severity: Major
Found in src/tasks/loadSiteManager.js and 2 other locations - About 1 hr to fix
src/tasks/loadSiteManager.js on lines 34..37
src/tasks/loadSiteManager.js on lines 39..42

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

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

    if (config.backupRepo)
        manager.backupRepoPath = path.resolve(manager.path, config.backupRepo);
    else
        manager.backupRepoPath = path.resolve(manager.path, 'backups.git');
Severity: Major
Found in src/tasks/loadSiteManager.js and 2 other locations - About 1 hr to fix
src/tasks/loadSiteManager.js on lines 28..31
src/tasks/loadSiteManager.js on lines 34..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 61.

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

    if (config.repo)
        manager._repoPath = path.resolve(manager.path, config.repo);
    else
        manager._repoPath = path.resolve(manager.path, 'repo.git');
Severity: Major
Found in src/tasks/loadSiteManager.js and 2 other locations - About 1 hr to fix
src/tasks/loadSiteManager.js on lines 28..31
src/tasks/loadSiteManager.js on lines 39..42

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

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

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

                  getSiteTasks: function(site) {
                      return $http.get('api/sites/' + site.name + '/tasks')
                      .then(function(res) {
                          return res.data.tasks;
                      });
      Severity: Major
      Found in public/js/model.js and 1 other location - About 1 hr to fix
      public/js/model.js on lines 110..115

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

      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

                  model.getSite($routeParams.site)
                      .then(function(site) {
                          $scope.site = site;
      
                          return model.getBackup(site, $routeParams.revision);
      Severity: Major
      Found in public/js/controllers.js and 1 other location - About 1 hr to fix
      public/js/controllers.js on lines 146..153

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

      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

                  model.getSite($routeParams.site)
                  .then(function(site) {
                      $scope.site = site;
                      return model.getTask(site, $routeParams.id);
                  })
      Severity: Major
      Found in public/js/controllers.js and 1 other location - About 1 hr to fix
      public/js/controllers.js on lines 106..117

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

      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

                  getBackups: function(site) {
                      return $http.get('api/sites/' + site.name + '/backups')
                          .then(function(res) {
                              return res.data.backups;
                          });
      Severity: Major
      Found in public/js/model.js and 1 other location - About 1 hr to fix
      public/js/model.js on lines 95..100

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

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

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

          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

            Function getTasks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            PersistentTaskContext.prototype.getTasks = Q.async(function*(offset, count) {
                var tasks = [];
                if (offset < this._tasksInMemory.length) {
                    tasks = this._tasksInMemory.slice(offset, offset + count);
                    count -= tasks.length;
            Severity: Minor
            Found in src/persistentTaskContext.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

            Avoid deeply nested control flow statements.
            Open

                        for (name in object) {
                            if (name[0] == '_' || name in dest)
                                continue;
                            var result = extract(object[name], true /* only primitives */);
                            if (result !== null)
            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

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

                            this.site.upstreamRevision = (yield this.exec("git rev-parse origin/" + this.site.branch)).stdout.trim();
                Severity: Minor
                Found in src/tasks/loadSite.js and 1 other location - About 40 mins to fix
                src/tasks/loadSite.js on lines 31..31

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

                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