Function _getTypeFromMongoose
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
_getTypeFromMongoose(fieldInfo) {
if (_.isPlainObject(fieldInfo) && !fieldInfo.path) {
// Deal with Object
return this._objectType(
fieldInfo,
- 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 _getTypeFromNative
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
_getTypeFromNative(type) {
if (type instanceof Array) {
if (_.isEmpty(type)) {
return [null];
}
- 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 _getTypeFromMongoose
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getTypeFromMongoose(fieldInfo) {
if (_.isPlainObject(fieldInfo) && !fieldInfo.path) {
// Deal with Object
return this._objectType(
fieldInfo,
Function _detectReference
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
_detectReference(fieldInfo) {
if (fieldInfo.options) {
if (fieldInfo.options.ref && fieldInfo.options.type) {
const ref = this._formatRef(fieldInfo.options.ref);
return ref ? `${ref}._id` : null;
- 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 _getValidations
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static _getValidations(fieldInfo) {
const validations = [];
if (fieldInfo.validators && fieldInfo.validators.length > 0) {
_.each(fieldInfo.validators, (validator) => {
Function _getTypeFromNative
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getTypeFromNative(type) {
if (type instanceof Array) {
if (_.isEmpty(type)) {
return [null];
}
Function getFieldSchema
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
getFieldSchema(path, fieldInfo) {
const schema = { field: path, type: this._getTypeFromMongoose(fieldInfo) };
const ref = this._detectReference(fieldInfo);
if (ref) { schema.reference = ref; }
Function getFieldSchema
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
getFieldSchema(path, fieldInfo) {
const schema = { field: path, type: this._getTypeFromMongoose(fieldInfo) };
const ref = this._detectReference(fieldInfo);
if (ref) { schema.reference = ref; }
- 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 'Json';
Avoid too many return
statements within this function. Open
return this._schemaType(type);
Avoid too many return
statements within this function. Open
return null;
Avoid too many return
statements within this function. Open
return 'Json';
Avoid too many return
statements within this function. Open
return 'String';
Avoid too many return
statements within this function. Open
return this._getTypeFromNative(type.type);
Avoid too many return
statements within this function. Open
return [this._objectType(fieldInfo.options.type[0], (key) =>
this._getTypeFromNative(fieldInfo.options.type[0][key]))];
Avoid too many return
statements within this function. Open
return 'String';
Avoid too many return
statements within this function. Open
return [this._getTypeFromNative(fieldInfo.options.type[0])];
Avoid too many return
statements within this function. Open
return 'Enum';
Avoid too many return
statements within this function. Open
return fieldInfo.instance
|| (fieldInfo.options && this._getTypeFromNative(fieldInfo.options.type))
|| null;
Avoid too many return
statements within this function. Open
return this._objectType(fieldInfo.schema.obj, (fieldName) =>
this._getTypeFromNative(fieldInfo.schema.obj[fieldName]));
Avoid too many return
statements within this function. Open
return this._objectType(type, (key) => this._getTypeFromNative(type[key]));