onesupercoder/rack-livereload

View on GitHub

Showing 20 of 20 total issues

File livereload.js has 974 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function() {
    var __customevents = {}, __protocol = {}, __connector = {}, __timer = {}, __options = {}, __reloader = {}, __livereload = {}, __less = {}, __startup = {};

// customevents
    var CustomEvents;
Severity: Major
Found in js/livereload.js - About 2 days to fix

    Function LiveReload has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function LiveReload(window) {
                var _this = this;
                this.window = window;
                this.listeners = {};
                this.plugins = [];
    Severity: Major
    Found in js/livereload.js - About 2 hrs to fix

      Function reloadStylesheet has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  Reloader.prototype.reloadStylesheet = function(path) {
                      var imported, link, links, match, style, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1,
                          _this = this;
                      links = (function() {
                          var _i, _len, _ref, _results;
      Severity: Major
      Found in js/livereload.js - About 2 hrs to fix

        File web_socket.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
        // License: New BSD License
        // Reference: http://dev.w3.org/html5/websockets/
        // Reference: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10
        
        
        Severity: Minor
        Found in js/web_socket.js - About 2 hrs to fix

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

            WebSocket.__initialize = function() {
              if (WebSocket.__flash) return;
              
              if (WebSocket.__swfLocation) {
                // For backword compatibility.
          Severity: Minor
          Found in js/web_socket.js - About 1 hr to fix

            Function process has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    Parser.prototype.process = function(data) {
                        var command, message, options, _ref;
                        try {
                            if (!(this.protocol != null)) {
                                if (data.match(/^!!ver:([\d.]+)$/)) {
            Severity: Minor
            Found in js/livereload.js - About 1 hr to fix

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

                      function Connector(options, WebSocket, Timer, handlers) {
                          var _this = this;
                          this.options = options;
                          this.WebSocket = WebSocket;
                          this.Timer = Timer;
              Severity: Minor
              Found in js/livereload.js - About 1 hr to fix

                Function reattachStylesheetLink has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                            Reloader.prototype.reattachStylesheetLink = function(link) {
                                var clone, parent,
                                    _this = this;
                                if (link.__LiveReload_pendingRemoval) {
                                    return;
                Severity: Minor
                Found in js/livereload.js - About 1 hr to fix

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

                              if ((index = url.indexOf('#')) >= 0) {
                                  hash = url.slice(index);
                                  url = url.slice(0, index);
                              } else {
                                  hash = '';
                  Severity: Major
                  Found in js/livereload.js and 1 other location - About 1 hr to fix
                  js/livereload.js on lines 382..387

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

                  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 ((index = url.indexOf('?')) >= 0) {
                                  params = url.slice(index);
                                  url = url.slice(0, index);
                              } else {
                                  params = '';
                  Severity: Major
                  Found in js/livereload.js and 1 other location - About 1 hr to fix
                  js/livereload.js on lines 376..381

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

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

                              Reloader.prototype.reattachImportedRule = function(_arg) {
                                  var href, index, link, media, newRule, parent, rule, tempLink,
                                      _this = this;
                                  rule = _arg.rule, index = _arg.index, link = _arg.link;
                                  parent = rule.parentStyleSheet;
                  Severity: Minor
                  Found in js/livereload.js - About 1 hr to fix

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

                                Reloader.prototype.reloadImages = function(path) {
                                    var expando, img, selector, styleNames, styleSheet, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _results;
                                    expando = this.generateUniqueString();
                                    _ref = this.document.images;
                                    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                    Severity: Minor
                    Found in js/livereload.js - About 1 hr to fix

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

                                  Reloader.prototype.reload = function(path, options) {
                                      var plugin, _base, _i, _len, _ref;
                                      this.options = options;
                                      if ((_base = this.options).stylesheetReloadTimeout == null) {
                                          _base.stylesheetReloadTimeout = 15000;
                      Severity: Minor
                      Found in js/livereload.js - About 1 hr to fix

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

                                    Reloader.prototype.waitUntilCssLoads = function(clone, func) {
                                        var callbackExecuted, executeCallback, poll,
                                            _this = this;
                                        callbackExecuted = false;
                                        executeCallback = function() {
                        Severity: Minor
                        Found in js/livereload.js - About 1 hr to fix

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

                                                  case 'handshake-timeout':
                                                      return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + " (handshake timeout), will retry in " + nextDelay + " sec.");
                          Severity: Major
                          Found in js/livereload.js and 3 other locations - About 1 hr to fix
                          js/livereload.js on lines 879..880
                          js/livereload.js on lines 881..882
                          js/livereload.js on lines 885..886

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

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

                                                  case 'cannot-connect':
                                                      return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + ", will retry in " + nextDelay + " sec.");
                          Severity: Major
                          Found in js/livereload.js and 3 other locations - About 1 hr to fix
                          js/livereload.js on lines 881..882
                          js/livereload.js on lines 883..884
                          js/livereload.js on lines 885..886

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

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

                                                  case 'broken':
                                                      return _this.log("LiveReload disconnected from " + _this.options.host + ":" + _this.options.port + ", reconnecting in " + nextDelay + " sec.");
                          Severity: Major
                          Found in js/livereload.js and 3 other locations - About 1 hr to fix
                          js/livereload.js on lines 879..880
                          js/livereload.js on lines 883..884
                          js/livereload.js on lines 885..886

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

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

                                                  case 'handshake-failed':
                                                      return _this.log("LiveReload cannot connect to " + _this.options.host + ":" + _this.options.port + " (handshake failed), will retry in " + nextDelay + " sec.");
                          Severity: Major
                          Found in js/livereload.js and 3 other locations - About 1 hr to fix
                          js/livereload.js on lines 879..880
                          js/livereload.js on lines 881..882
                          js/livereload.js on lines 883..884

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

                          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

                                                  if ((keyAndValue = pair.split('=')).length > 1) {
                                                      options.set(keyAndValue[0].replace(/-/g, '_'), keyAndValue.slice(1).join('='));
                                                  }
                          Severity: Major
                          Found in js/livereload.js - About 45 mins to fix

                            Method _call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _call(env)
                                  _, path, file = (env['PATH_INFO'] || '').split('/')
                            
                                  if path == '__rack' && ::File.file?(target = ::File.expand_path("../../../js/#{file}", __FILE__))
                                    deliver_file(target)
                            Severity: Minor
                            Found in lib/rack/livereload.rb - 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

                            Severity
                            Category
                            Status
                            Source
                            Language