Showing 124 of 263 total issues
Function ResourceDeserializer
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ResourceDeserializer(Implementation, model, params, withRelationships, opts) {
if (!opts) { opts = {}; }
const schema = Schemas.schemas[Implementation.getModelName(model)];
function extractAttributes() {
Function validateOptions
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
validateOptions() {
const options = this.lianaOptions;
if (!options) {
throw new Error('Liana options cannot be 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 smartAction
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
smartAction() {
return [
async (request, response, next) => {
// We forbid requester_id from default request as it's only retrieved from
// signed_approval_request
File routes.js
has 263 lines of code (exceeds 250 allowed). Consider refactoring. Open
const { inject } = require('@forestadmin/context');
const _ = require('lodash');
const IntegrationInformationsGetter = require('../../services/integration-informations-getter');
const PaymentsGetter = require('./services/payments-getter');
const PaymentGetter = require('./services/payment-getter');
Function getDateFilter
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.getDateFilter = (operator, value) => {
value = Number.parseInt(value, 10);
switch (operator) {
case 'today':
Function validateField
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
validateField(field, actionName) {
if (!field || Array.isArray(field) || typeof field !== 'object') throw new Error(`Field inside fields array on the smart action "${actionName}" must be an object.`);
const {
field: fieldName,
- 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 serializeSubscriptions
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function serializeSubscriptions(subscriptions, collectionName, meta) {
function getCustomerAttributes() {
if (!subscriptions.length) { return []; }
const schema = Schemas.schemas[collectionName];
Function createCollections
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.createCollections = (Implementation, apimap, collectionAndFieldName) => {
const { modelsManager } = inject();
// jshint camelcase: false
const collectionName = collectionAndFieldName.split('.')[0];
const model = modelsManager.getModels()[collectionName];
Function serializeConversations
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function serializeConversations(conversations, collectionName, meta) {
function mapConversation(conversation) {
// jshint camelcase: false
conversation.id = conversation.id.replace('layer:///conversations/', '');
conversation.createdAt = conversation.created_at;
Function serializeInvoices
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function serializeInvoices(invoices, collectionName, meta) {
function getCustomerAttributes() {
if (!invoices.length) { return []; }
const schema = Schemas.schemas[collectionName];
- 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 getAttributesFor
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getAttributesFor(dest, fields) {
_.map(fields, (field) => {
detectFieldWithSpecialFormat(field);
if (field.integration) {
Function getPreviousDateFilter
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.getPreviousDateFilter = (operator, value) => {
value = Number.parseInt(value, 10);
switch (operator) {
case 'today': {
Function prettyPrint
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
const prettyPrint = (json, indentation = '') => {
let result = '';
if (_.isArray(json)) {
result += '[';
Function perform
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.perform = () => {
app.get(
`${path.generate(modelName, lianaOptions)}.csv`,
auth.ensureAuthenticated,
permissionMiddlewareCreator.export(),
Function createCollections
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.createCollections = (Implementation, apimap, collectionName) => {
const { modelsManager } = inject();
const collectionDisplayName = _.capitalize(collectionName);
const model = modelsManager.getModels()[collectionName];
// jshint camelcase: false
Function collection
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.collection = (name, opts) => {
if (_.isEmpty(Schemas.schemas) && opts.modelsDir) {
logger.error(`Cannot customize your collection named "${name}" properly. Did you call the "collection" method in the /forest directory?`);
return;
}
Function IntegrationChecker
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function IntegrationChecker(opts, Implementation) {
const modules = [
new CloseIo(opts, Implementation),
new Intercom(opts, Implementation),
new Layer(opts, Implementation),
- 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 createFields
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.createFields = (implementation, model, schemaFields) => {
schemaFields.push({
field: 'stripe_payments',
displayName: 'Payments',
type: ['String'],
Function perform
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.perform = () => {
const {
collection: collectionModel,
field: collectionFieldName,
embeddedPath,
Function perform
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
.then((contact) => {
if (!contact || !contact.body || !contact.body.data || !contact.body.data[0]) {
logger.error('Cannot access to Intercom conversations: No intercom contact matches the given key');
return [0, []];
}