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');
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
- Read upRead up
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
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;
}
- Read upRead up
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 = {
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');
}
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;
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)) {
- Read upRead up
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 replaceAddressWithCoordinates
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
replaceAddressWithCoordinates(params, addressField, latField, lngField, callback) {
Avoid too many return
statements within this function. Open
return false;
Function getCoordinatesForAddress
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Uber.prototype.getCoordinatesForAddress = function getCoordinatesForAddress(address, callback) {
this.geocoder.geocode(address, function (err, data) {
if (err || data.length === 0) {
return callback((err
? err
- Read upRead up
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 replaceAddressWithCoordinates
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Uber.prototype.replaceAddressWithCoordinates = function
replaceAddressWithCoordinates(params, addressField, latField, lngField, callback) {
if (this.hasOwnNestedProperty(params, addressField) && !this.getNestedProperty(params, latField) && !this.getNestedProperty(params, lngField)) {
// get coordinates from address
this.getCoordinatesForAddress(this.getNestedProperty(params, addressField), function (err, data) {
- Read upRead up
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"