hendolim/countonanon

View on GitHub
faye-1.1.2/lib/faye-browser.js

Summary

Maintainability
F
1 wk
Test Coverage

File faye-browser.js has 1910 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function() {
'use strict';

var Faye = {
  VERSION:          '1.1.2',
Severity: Major
Found in faye-1.1.2/lib/faye-browser.js - About 5 days to fix

    Function str has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function str(key, holder) {
    
    // Produce a string from holder[key].
    
            var i,          // The loop counter.
    Severity: Major
    Found in faye-1.1.2/lib/faye-browser.js - About 2 hrs to fix

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

        connect: function() {
          if (Faye.Transport.WebSocket._unloaded) return;
      
          this._state = this._state || this.UNCONNECTED;
          if (this._state !== this.UNCONNECTED) return;
      Severity: Minor
      Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

        Function emit has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        EventEmitter.prototype.emit = function(type) {
          // If there is no 'error' event listener then throw.
          if (type === 'error') {
            if (!this._events || !this._events.error ||
                (isArray(this._events.error) && !this._events.error.length))
        Severity: Minor
        Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

          Function request has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            request: function(messages) {
              var xhrClass = Faye.ENV.XDomainRequest ? XDomainRequest : XMLHttpRequest,
                  xhr      = new xhrClass(),
                  id       = ++Faye.Transport.CORS._id,
                  headers  = this._dispatcher.headers,
          Severity: Minor
          Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

            Function parse has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              parse: function(url) {
                if (typeof url !== 'string') return url;
                var uri = {}, parts, query, pairs, i, n, data;
            
                var consume = function(name, pattern) {
            Severity: Minor
            Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

              Function parse has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      JSON.parse = function (text, reviver) {
              
              // The parse method takes a text and an optional reviver function, and returns
              // a JavaScript value if the text is a valid JSON text.
              
              
              Severity: Minor
              Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

                Function request has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  request: function(messages) {
                    var href = this.endpoint.href,
                        xhr  = Faye.ENV.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest(),
                        self = this;
                
                
                Severity: Minor
                Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                        if ((element    && element    !== register._element)   ||
                            (eventName  && eventName  !== register._type)      ||
                            (callback   && callback   !== register._callback)  ||
                            (context      && context      !== register._context))
                          continue;
                  Severity: Critical
                  Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

                    Function subscribe has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      subscribe: function(channel, callback, context) {
                        if (channel instanceof Array)
                          return Faye.map(channel, function(c) {
                            return this.subscribe(c, callback, context);
                          }, this);
                    Severity: Minor
                    Found in faye-1.1.2/lib/faye-browser.js - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if (v) {
                                                  partial.push(quote(k) + (gap ? ': ' : ':') + v);
                                              }
                      Severity: Major
                      Found in faye-1.1.2/lib/faye-browser.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (v !== undefined) {
                                                        value[k] = v;
                                                    } else {
                                                        delete value[k];
                                                    }
                        Severity: Major
                        Found in faye-1.1.2/lib/faye-browser.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if (v) {
                                                      partial.push(quote(k) + (gap ? ': ' : ':') + v);
                                                  }
                          Severity: Major
                          Found in faye-1.1.2/lib/faye-browser.js - About 45 mins to fix

                            Function pipeThroughExtensions has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              pipeThroughExtensions: function(stage, message, request, callback, context) {
                            Severity: Minor
                            Found in faye-1.1.2/lib/faye-browser.js - About 35 mins to fix

                              Function get has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                get: function(dispatcher, allowed, disabled, callback, context) {
                              Severity: Minor
                              Found in faye-1.1.2/lib/faye-browser.js - About 35 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return true;
                                Severity: Major
                                Found in faye-1.1.2/lib/faye-browser.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      return false;
                                  Severity: Major
                                  Found in faye-1.1.2/lib/faye-browser.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        if (this._connectRequest) return;
                                    Severity: Major
                                    Found in faye-1.1.2/lib/faye-browser.js - About 30 mins to fix

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

                                      var registerOnFulfilled = function(promise, onFulfilled, next) {
                                        if (typeof onFulfilled !== 'function') onFulfilled = RETURN;
                                        var handler = function(value) { invoke(onFulfilled, value, next) };
                                      
                                        if (promise._state === PENDING) {
                                      Severity: Major
                                      Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 3 hrs to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 416..425

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

                                      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

                                      var registerOnRejected = function(promise, onRejected, next) {
                                        if (typeof onRejected !== 'function') onRejected = THROW;
                                        var handler = function(reason) { invoke(onRejected, reason, next) };
                                      
                                        if (promise._state === PENDING) {
                                      Severity: Major
                                      Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 3 hrs to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 405..414

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

                                      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

                                      var _fulfill = function(promise, value) {
                                        if (promise._state !== PENDING) return;
                                      
                                        promise._state      = FULFILLED;
                                        promise._value      = value;
                                      Severity: Major
                                      Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 2 hrs to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 480..489

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

                                      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

                                      var reject = Promise.reject = function(promise, reason) {
                                        if (promise._state !== PENDING) return;
                                      
                                        promise._state       = REJECTED;
                                        promise._reason      = reason;
                                      Severity: Major
                                      Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 2 hrs to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 469..478

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

                                      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

                                                      v = partial.length === 0
                                                          ? '[]'
                                                          : gap
                                                          ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
                                                          : '[' + partial.join(',') + ']';
                                      Severity: Major
                                      Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 2 hrs to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 2208..2212

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

                                      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

                                                  v = partial.length === 0
                                                      ? '{}'
                                                      : gap
                                                      ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
                                                      : '{' + partial.join(',') + '}';
                                      Severity: Major
                                      Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 2 hrs to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 2169..2173

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

                                      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

                                          for (var i = 0, n = messages.length; i < n; i++) this._pending.add(messages[i]);
                                      Severity: Minor
                                      Found in faye-1.1.2/lib/faye-browser.js and 2 other locations - About 40 mins to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 1739..1740
                                      faye-1.1.2/lib/faye-browser.js on lines 1749..1750

                                      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

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

                                          for (var i = 0, n = replies.length; i < n; i++)
                                            this._dispatcher.handleResponse(replies[i]);
                                      Severity: Minor
                                      Found in faye-1.1.2/lib/faye-browser.js and 2 other locations - About 40 mins to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 1749..1750
                                      faye-1.1.2/lib/faye-browser.js on lines 2366..2366

                                      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

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

                                          for (var i = 0, n = messages.length; i < n; i++)
                                            this._dispatcher.handleError(messages[i]);
                                      Severity: Minor
                                      Found in faye-1.1.2/lib/faye-browser.js and 2 other locations - About 40 mins to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 1739..1740
                                      faye-1.1.2/lib/faye-browser.js on lines 2366..2366

                                      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

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

                                        isService: function(name) {
                                          var segments = this.parse(name);
                                          return segments ? (segments[0] === this.SERVICE) : null;
                                        },
                                      Severity: Minor
                                      Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 35 mins to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 997..1000

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

                                      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

                                        isMeta: function(name) {
                                          var segments = this.parse(name);
                                          return segments ? (segments[0] === this.META) : null;
                                        },
                                      Severity: Minor
                                      Found in faye-1.1.2/lib/faye-browser.js and 1 other location - About 35 mins to fix
                                      faye-1.1.2/lib/faye-browser.js on lines 1002..1005

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

                                      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