conveyal/modeify

View on GitHub
client/components/visionmedia/superagent/v1.1.0/lib/client.js

Summary

Maintainability
F
4 days
Test Coverage

File client.js has 414 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Module dependencies.
 */

var Emitter = require('emitter');
Severity: Minor
Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js - About 5 hrs to fix

    Function end has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    Request.prototype.end = function(fn){
      var self = this;
      var xhr = this.xhr = request.getXHR();
      var query = this._query.join('&');
      var timeout = this._timeout;
    Severity: Minor
    Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function send has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    Request.prototype.send = function(data){
      var obj = isObject(data);
      var type = this.getHeader('Content-Type');
    
      // merge
    Severity: Minor
    Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function end has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Request.prototype.end = function(fn){
      var self = this;
      var xhr = this.xhr = request.getXHR();
      var query = this._query.join('&');
      var timeout = this._timeout;
    Severity: Major
    Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js - About 2 hrs to fix

      Function getXHR has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      request.getXHR = function () {
        if (root.XMLHttpRequest
          && ('file:' != root.location.protocol || !root.ActiveXObject)) {
          return new XMLHttpRequest;
        } else {
      Severity: Minor
      Found in client/components/visionmedia/superagent/v1.1.0/lib/client.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 Request has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Request(method, url) {
        var self = this;
        Emitter.call(this);
        this._query = this._query || [];
        this.method = method;
      Severity: Minor
      Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js - About 1 hr to fix

        Function Response has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function Response(req, options) {
          options = options || {};
          this.req = req;
          this.xhr = this.req.xhr;
          // responseText is accessible only if responseType is '' or 'text' and on older browsers
        Severity: Minor
        Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js - About 35 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 too many return statements within this function.
        Open

          return false;
        Severity: Major
        Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}
          Severity: Major
          Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js - About 30 mins to fix

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

            request.post = function(url, data, fn){
              var req = request('POST', url);
              if ('function' == typeof data) fn = data, data = null;
              if (data) req.send(data);
              if (fn) req.end(fn);
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1012..1018
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1030..1036
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1063..1069
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1099..1105

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

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

            request.head = function(url, data, fn){
              var req = request('HEAD', url);
              if ('function' == typeof data) fn = data, data = null;
              if (data) req.send(data);
              if (fn) req.end(fn);
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1012..1018
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1063..1069
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1081..1087
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1099..1105

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

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

            request.patch = function(url, data, fn){
              var req = request('PATCH', url);
              if ('function' == typeof data) fn = data, data = null;
              if (data) req.send(data);
              if (fn) req.end(fn);
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1012..1018
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1030..1036
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1081..1087
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1099..1105

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

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

            request.put = function(url, data, fn){
              var req = request('PUT', url);
              if ('function' == typeof data) fn = data, data = null;
              if (data) req.send(data);
              if (fn) req.end(fn);
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1012..1018
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1030..1036
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1063..1069
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1081..1087

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

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

            request.get = function(url, data, fn){
              var req = request('GET', url);
              if ('function' == typeof data) fn = data, data = null;
              if (data) req.query(data);
              if (fn) req.end(fn);
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1030..1036
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1063..1069
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1081..1087
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 1099..1105

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

            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

            Request.prototype.type = function(type){
              this.set('Content-Type', request.types[type] || type);
              return this;
            };
            Severity: Minor
            Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js and 1 other location - About 50 mins to fix
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 656..659

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

            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

            Request.prototype.accept = function(type){
              this.set('Accept', request.types[type] || type);
              return this;
            };
            Severity: Minor
            Found in client/components/visionmedia/superagent/v1.1.0/lib/client.js and 1 other location - About 50 mins to fix
            client/components/visionmedia/superagent/v1.1.0/lib/client.js on lines 631..634

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

            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