shernshiou/node-uber

View on GitHub

Showing 31 of 31 total issues

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

PartnerTrips.prototype.getTrips = function getTrips(off, lim, from, to, callback) {
  var newOffset = off || 0;
  // ensure query limit is set. Maximum is 50. Default is 5.
  var newLimit = (lim)
    ? Math.min(lim, 50)
Severity: Major
Found in lib/resources/drivers/PartnerTrips.js and 1 other location - About 7 hrs to fix
lib/resources/drivers/PartnerPayments.js on lines 9..35

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

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

PartnerPayments.prototype.getPayments = function getPayments(off, lim, from, to, callback) {
  var newOffset = off || 0;
  // ensure query limit is set. Maximum is 50. Default is 5.
  var newLimit = (lim)
    ? Math.min(lim, 50)
Severity: Major
Found in lib/resources/drivers/PartnerPayments.js and 1 other location - About 7 hrs to fix
lib/resources/drivers/PartnerTrips.js on lines 9..35

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

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

File Uber.js has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var request = require('request');
var qs = require('querystring');
var OAuth = require('oauth');
var util = require('util');
var Promise = require('bluebird');
Severity: Minor
Found in lib/Uber.js - About 5 hrs to fix

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

    Requests.prototype.getMapByID = function getMapByID(id, callback) {
        if (!id) {
            return callback(new Error('Invalid request_id'));
        }
    
    
    Severity: Major
    Found in lib/resources/riders/Requests.js and 1 other location - About 3 hrs to fix
    lib/resources/riders/Requests.js on lines 108..117

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 95.

    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

    Requests.prototype.getReceiptByID = function getReceiptByID(id, callback) {
        if (!id) {
            return callback(new Error('Invalid request_id'));
        }
    
    
    Severity: Major
    Found in lib/resources/riders/Requests.js and 1 other location - About 3 hrs to fix
    lib/resources/riders/Requests.js on lines 97..106

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

    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 modifierMethodHelper has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    Uber.prototype.modifierMethodHelper = function modifierMethodHelper(options, callback, method) {
      var access_type;
      var self = this;
      var localCallback = function localCallback(err, data, res) {
        // shared callback between put, post, patch, and delete requests
    Severity: Minor
    Found in lib/Uber.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 modifierMethodHelper has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Uber.prototype.modifierMethodHelper = function modifierMethodHelper(options, callback, method) {
      var access_type;
      var self = this;
      var localCallback = function localCallback(err, data, res) {
        // shared callback between put, post, patch, and delete requests
    Severity: Major
    Found in lib/Uber.js - About 2 hrs to fix

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

      Requests.prototype.create = function create(parameters, callback) {
          var self = this;
          if (!parameters) {
              return callback(new Error('Invalid parameters'));
          }
      Severity: Major
      Found in lib/resources/riders/Requests.js - About 2 hrs to fix

        Function checkScopes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        Uber.prototype.checkScopes = function checkScopes(options) {
          if (!options || !options.scope) {
            // checking scopes is not relevant
            return true;
          }
        Severity: Minor
        Found in lib/Uber.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 Uber has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Uber(options) {
          this.sandbox = options.sandbox
            ? options.sandbox
            : false;
          this.defaults = {
        Severity: Minor
        Found in lib/Uber.js - About 1 hr to fix

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

          Estimates.prototype.getPriceForRouteByAddress = function getPriceForRouteByAddress(startAddress, endAddress, seats, callback) {
              this._uber.getCoordinatesForAddress(startAddress, function(err, startData) {
                  if(err) {
                      // check first if seats (optional) is provided
                      return (typeof seats === 'function' ? seats(err) : callback(err));
          Severity: Minor
          Found in lib/resources/riders/Estimates.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 updateByID has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Requests.prototype.updateByID = function updateByID(id, parameters, callback) {
              if (!id) {
                  return callback(new Error('Invalid request_id'));
              }
          
          
          Severity: Minor
          Found in lib/resources/riders/Requests.js - About 1 hr to fix

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

            Uber.prototype.get = function get(options, callback) {
              var access_type = this.createAccessHeader(options.server_token);
              if (!access_type) {
                return callback(new Error('Invalid access token'), 'A valid access token is required for this request');
              }
            Severity: Minor
            Found in lib/Uber.js - About 1 hr to fix

              Function authorization has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Uber.prototype.authorization = function authorization(options, callback) {
                var self = this;
                var grantType = '';
                var code = '';
                var nD = null;
              Severity: Minor
              Found in lib/Uber.js - About 1 hr to fix

                Function getEstimates has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Requests.prototype.getEstimates = function getEstimates(parameters, callback) {
                    if (!parameters) {
                        return callback(new Error('Invalid parameters'));
                    }
                
                
                Severity: Minor
                Found in lib/resources/riders/Requests.js - About 1 hr to fix

                  Function create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Requests.prototype.create = function create(parameters, callback) {
                      var self = this;
                      if (!parameters) {
                          return callback(new Error('Invalid parameters'));
                      }
                  Severity: Minor
                  Found in lib/resources/riders/Requests.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

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

                  var uber = new Uber({
                      client_id: 'YOUR CLIENT ID',
                      client_secret: 'YOUR CLIENT SECRET',
                      server_token: 'YOUR SERVER TOKEN',
                      redirect_uri: 'http://localhost/callback',
                  Severity: Minor
                  Found in examples/auth-get-products-async.js and 1 other location - About 50 mins to fix
                  examples/auth-get-products.js on lines 4..12

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

                  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 uber = new Uber({
                      client_id: 'YOUR CLIENT ID',
                      client_secret: 'YOUR CLIENT SECRET',
                      server_token: 'YOUR SERVER TOKEN',
                      redirect_uri: 'http://localhost/callback',
                  Severity: Minor
                  Found in examples/auth-get-products.js and 1 other location - About 50 mins to fix
                  examples/auth-get-products-async.js on lines 4..12

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

                  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 removeNestedProperty has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Uber.prototype.removeNestedProperty = function removeNestedProperty(obj, key) {
                    var props = key.split('.');
                    var propName = props[props.length - 1];
                    for (var p in obj) {
                      if (obj.hasOwnProperty(p)) {
                  Severity: Minor
                  Found in lib/Uber.js - About 45 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

                  Function getPriceForRoute has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  Estimates.prototype.getPriceForRoute = function getPriceForRoute(startLat,
                      startLon, endLat, endLon, seats, callback) {
                  Severity: Minor
                  Found in lib/resources/riders/Estimates.js - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language