Showing 45 of 53 total issues
Function buildArgs
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
HttpContext.prototype.buildArgs = function(method) {
var args = {};
var ctx = this;
var accepts = method.accepts;
- 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
File api_method.js
has 386 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* Expose `ApiMethod`.
*/
module.exports = ApiMethod;
File http.js
has 343 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* Expose `HttpContext`.
*/
module.exports = HttpContext;
Function Validate
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
function Validate(params, accepts) {
var validationError = new ValidationError();
params = params || {};
accepts = accepts || [];
- 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 invoke
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
ApiMethod.prototype.invoke = function(ctx, cb) {
var args = ctx.args;
var options = util._extend({}, ctx.options);
var returns = this.returns;
- 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 invoke
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
ApiMethod.prototype.invoke = function(ctx, cb) {
var args = ctx.args;
var options = util._extend({}, ctx.options);
var returns = this.returns;
Function buildArgs
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
HttpContext.prototype.buildArgs = function(method) {
var args = {};
var ctx = this;
var accepts = method.accepts;
Function done
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
HttpContext.prototype.done = function() {
// if response is already returned, then do nothing
if (this._done) return;
- 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 getArgByName
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
HttpContext.prototype.getArgByName = function(name, options) {
var req = this.req;
var args = req.params && req.params.args !== undefined ? req.params.args :
req.body && req.body.args !== undefined ? req.body.args :
req.query && req.query.args !== undefined ? req.query.args :
- 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 toResult
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
ApiMethod.toResult = function(raw, presenter, presenterSource, options) {
if (Entity.isEntity(presenter)) {
var result = presenter.parse(_eval(raw, presenterSource), options, _convert);
return _eval(raw, presenterSource, result);
} else {
- 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 add
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Entity.prototype.add = function() {
// ...names, options, fn
var message = '\'%s\' is not a valid string';
var self = this;
Function parse
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Entity.prototype.parse = function(input, options, converter) {
debug('parsing %j with options %j and converter', input, options);
var originalObj;
var result = {};
var self = this;
Function errorHandler
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
RestAdapter.errorHandler = function(options) {
options = options || {};
return function restErrorHandler(err, req, res, next) {
if (typeof options.errorHandler === 'function') {
try {
- 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 createHandler
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
RestAdapter.prototype.createHandler = function() {
var router = express.Router(this.options);
var adapter = this;
var methods = this.api.allMethods();
Function toResult
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
ApiMethod.toResult = function(raw, presenter, presenterSource, options) {
if (Entity.isEntity(presenter)) {
var result = presenter.parse(_eval(raw, presenterSource), options, _convert);
return _eval(raw, presenterSource, result);
} else {
Function applyDelegates
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
HttpContext.prototype.applyDelegates = function(method) {
var proto = this;
/**
* Response delegation.
*/
Function Validate
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Validate(params, accepts) {
var validationError = new ValidationError();
params = params || {};
accepts = accepts || [];
Function done
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
HttpContext.prototype.done = function() {
// if response is already returned, then do nothing
if (this._done) return;
Function coerceAccepts
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function coerceAccepts(uarg, desc) {
var name = desc.name || desc.arg;
var targetType = convertToBasicType(desc.type);
var targetTypeIsArray = _.isArray(targetType) && targetType.length === 1;
Function Sanitize
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Sanitize(params, accepts) {
params = params || {};
accepts = accepts || [];
_.each(accepts, function(accept) {