Showing 42 of 66 total issues
Function init
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
exports.init = (opts) => {
exports.opts = opts;
if (!opts.objectMapping) {
Interface.logger.error('The objectMapping option appears to be missing. Please make sure it is set correctly.');
- 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 FiltersParser
has 183 lines of code (exceeds 25 allowed). Consider refactoring. Open
function FiltersParser(model, timezone, options) {
const modelSchema = Interface.Schemas.schemas[utils.getModelName(model)];
const parseInteger = (value) => Number.parseInt(value, 10);
const parseDate = (value) => new Date(value);
Function FiltersParser
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
function FiltersParser(model, timezone, options) {
const modelSchema = Interface.Schemas.schemas[utils.getModelName(model)];
const parseInteger = (value) => Number.parseInt(value, 10);
const parseDate = (value) => new Date(value);
- 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 init
has 116 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.init = (opts) => {
exports.opts = opts;
if (!opts.objectMapping) {
Interface.logger.error('The objectMapping option appears to be missing. Please make sure it is set correctly.');
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 perform
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
async perform() {
const params = await getScopedParams(this._params, this._model, this._user);
const timezone = -parseInt(moment().tz(params.timezone).format('Z'), 10);
const timezoneOffset = timezone * 60 * 60 * 1000;
const queryBuilder = new QueryBuilder(this._model, params, this._opts);
Function SearchBuilder
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SearchBuilder(model, opts, params, searchFields) {
const schema = Interface.Schemas.schemas[utils.getModelName(model)];
const fieldsSearched = [];
this.hasSmartFieldSearch = false;
Function getConditions
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.getConditions = async () => {
this.hasSmartFieldSearch = false;
const orQuery = { $or: [] };
function pushCondition(condition, fieldName) {
exports
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
module.exports = class Flattener {
constructor(schema, flatten, model, lianaOptions) {
this.schema = schema;
this.flatten = flatten;
this.model = model;
File flattener.js
has 280 lines of code (exceeds 250 allowed). Consider refactoring. Open
import _ from 'lodash';
import Interface from 'forest-express';
import FieldIntrospector from '../utils/field-analyser';
import { getMongooseSchemaFromFieldPath } from '../utils/schema';
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 formatConditionForReferences
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.formatConditionForReferences = async (condition) => {
if (_.isEmpty(condition)) {
throw new InvalidFiltersFormatError('Empty condition in filter');
}
if (!_.isObject(condition)) {
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 formatOperatorValue
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.formatOperatorValue = async (field, operator, value) => {
if (this.operatorDateParser.isDateOperator(operator)) {
return this.operatorDateParser.getDateFilter(operator, value);
}
Function perform
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
async perform() {
const params = await getScopedParams(this._params, this._model, this._user);
const field = _.find(this._schema.fields, { field: params.groupByFieldName });
const queryBuilder = new QueryBuilder(this._model, params, this._opts);
const populateGroupByField = this._getReference(params.groupByFieldName);
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 getNestedFieldType
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const getNestedFieldType = (mongooseSchema, nestedFieldPath) => {
if (!mongooseSchema || !nestedFieldPath) return undefined;
const [currentFieldName, ...deepNestedFieldPath] = nestedFieldPath.split(FLATTEN_SEPARATOR);
- 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 _formatLabel
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static _formatLabel(record, momentRange) {
switch (momentRange) {
case 'day':
return moment()
.year(record._id.year)