beevelop/corci-monitor

View on GitHub
www/js/index.js

Summary

Maintainability
F
2 wks
Test Coverage

File index.js has 344 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var ioc = require('socket.io/node_modules/socket.io-client');
require('../../lib/common/utils.js');
var Msg = require('../../lib/common/Msg.js');
var ko = require('knockout');
var stringformat = require('stringformat');
Severity: Minor
Found in www/js/index.js - About 4 hrs to fix

    Function onPartialStatus has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        'onPartialStatus': function(status) {
            //console.warn('partial status', status);
            switch (status && status.what) {
                case 'agent':
                    update.call(this, this.agents);
    Severity: Major
    Found in www/js/index.js - About 3 hrs to fix

      Function update has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function update(list) {
                  list.map = list.map || {};
                  switch (status && status.kind) {
                      case 'log':
                          var build = status.obj;
      Severity: Major
      Found in www/js/index.js - About 2 hrs to fix

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

            'onStatus': function(status) {
                if (status) {
                    status.agents = status.agents || [];
                    this.logs((status.logs || []).map(function(log) {
                        return new Msg(log);
        Severity: Minor
        Found in www/js/index.js - About 1 hr to fix

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

          function ServerBrowser(conf) {
              this.conf = conf;
              this.logs = observableArray([]);
              this.agents = observableArray([]);
              this.builds = observableArray([]);
          Severity: Minor
          Found in www/js/index.js - About 1 hr to fix

            Function ServerBrowser has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            function ServerBrowser(conf) {
                this.conf = conf;
                this.logs = observableArray([]);
                this.agents = observableArray([]);
                this.builds = observableArray([]);
            Severity: Minor
            Found in www/js/index.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 update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                update: function(build) {
                    if (build && build.conf) {
                        var conf = build.conf;
                        this.conf = conf;
                        this.name(conf.name);
            Severity: Minor
            Found in www/js/index.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 update has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                update: function(build) {
                    if (build && build.conf) {
                        var conf = build.conf;
                        this.conf = conf;
                        this.name(conf.name);
            Severity: Minor
            Found in www/js/index.js - About 1 hr to fix

              Function onPartialStatus has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  'onPartialStatus': function(status) {
                      //console.warn('partial status', status);
                      switch (status && status.what) {
                          case 'agent':
                              update.call(this, this.agents);
              Severity: Minor
              Found in www/js/index.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 onStatus has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  'onStatus': function(status) {
                      if (status) {
                          status.agents = status.agents || [];
                          this.logs((status.logs || []).map(function(log) {
                              return new Msg(log);
              Severity: Minor
              Found in www/js/index.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

              Consider simplifying this complex logical expression.
              Open

                      if (status) {
                          status.agents = status.agents || [];
                          this.logs((status.logs || []).map(function(log) {
                              return new Msg(log);
                          }));
              Severity: Major
              Found in www/js/index.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                        if (build && build.conf) {
                            var conf = build.conf;
                            this.conf = conf;
                            this.name(conf.name);
                            this.platform(conf.platform);
                Severity: Major
                Found in www/js/index.js - About 1 hr to fix

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

                      'onPartialStatus': function(status) {
                          //console.warn('partial status', status);
                          switch (status && status.what) {
                              case 'agent':
                                  update.call(this, this.agents);
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 4 days to fix
                  www/js/bundle.js on lines 13082..13172

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

                  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

                  BuildVM.define({
                      update: function(build) {
                          if (build && build.conf) {
                              var conf = build.conf;
                              this.conf = conf;
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 4 days to fix
                  www/js/bundle.js on lines 13252..13297

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

                  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

                      'onStatus': function(status) {
                          if (status) {
                              status.agents = status.agents || [];
                              this.logs((status.logs || []).map(function(log) {
                                  return new Msg(log);
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 3 days to fix
                  www/js/bundle.js on lines 13173..13223

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

                  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

                      connect: function(url) {
                          this.socket = ioc.connect(url);
                          this.socket.heartbeatTimeout = 1000; // reconnect if not received heartbeat for 20 seconds
                  
                          this.socket.on('connect', this.onConnect.bind(this));
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 1 day to fix
                  www/js/bundle.js on lines 13044..13060

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

                  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

                  function BuildVM(build) {
                      this.conf = build && build.conf;
                      this.name = observable();
                      this.id = build && build.id;
                      this.platforms = observableArray();
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 1 day to fix
                  www/js/bundle.js on lines 13236..13250

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

                  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

                  if (inBrowser) {
                      window.ServerBrowser = ServerBrowser;
                      window.ko = ko;
                      setInterval(function() {
                          $('[datetime]').each(function() {
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 5 hrs to fix
                  www/js/bundle.js on lines 12944..12956

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

                  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

                      'onDisconnect': function() {
                          this.disconnectedSince(new Date());
                          this.status('disconnected');
                          this.agents([]);
                          this.builds([]);
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 5 hrs to fix
                  www/js/bundle.js on lines 13064..13075

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

                  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

                          if (build && tab != "info" && !build.conf.platform.findOne(function(platform) {
                              return platform == tab;
                          })) {
                              selectedTab("#info");
                          } else if (build) {
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 3 hrs to fix
                  www/js/bundle.js on lines 12993..13000

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

                  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

                  ko.bindingHandlers.hidden = {
                      update: function(element, valueAccessor) {
                          var isVisible = !ko.utils.unwrapObservable(valueAccessor());
                          ko.bindingHandlers.visible.update(element, function() {
                              return isVisible;
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 2 hrs to fix
                  www/js/bundle.js on lines 12960..12967

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

                  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

                      var url = '{0}{1}{2}/{3}'.format(conf.protocol || 'http://', conf.host || 'localhost', conf.port == 80 ? '' : ':' + conf.port, 'www');
                  Severity: Major
                  Found in www/js/index.js and 1 other location - About 1 hr to fix
                  www/js/bundle.js on lines 13003..13003

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

                      this.as.subscribe(function(as) {
                          $.cookie('as', as, {expires: 365});
                      }.bind(this));
                  Severity: Minor
                  Found in www/js/index.js and 1 other location - About 40 mins to fix
                  www/js/bundle.js on lines 13006..13008

                  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

                  There are no issues that match your filters.

                  Category
                  Status