File api_method.js
has 386 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* Expose `ApiMethod`.
*/
module.exports = ApiMethod;
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 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 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 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 _eval
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _eval(source, path, value) {
if (path && _.isString(path)) {
// split path by '[', '.', ']' and then remove empty string
var list = _.compact(path.trim().split(/\[|\.|\]/));
Function ApiMethod
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ApiMethod(name, options, fn) {
this.__original = [name, options, fn];
this.fn = fn;
Function getType
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
ApiMethod.getType = function(val) {
var type = typeof val;
switch (type) {
case 'undefined':
- 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 coerceAccepts
has a Cognitive Complexity of 8 (exceeds 5 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;
- 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 ApiMethod
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function ApiMethod(name, options, fn) {
this.__original = [name, options, fn];
this.fn = fn;
- 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
Avoid too many return
statements within this function. Open
return callback(err);
Avoid too many return
statements within this function. Open
return cb(e);
Avoid too many return
statements within this function. Open
return 'object';
Avoid too many return
statements within this function. Open
return uarg;