ForestAdmin/forest-express

View on GitHub

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() {
Severity: Major
Found in src/deserializers/resource.js - About 2 hrs to fix

    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.');
    Severity: Minor
    Found in src/services/config-store.js - About 2 hrs to fix

    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
    Severity: Major
    Found in src/middlewares/permissions.js - About 2 hrs to fix

      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');
      Severity: Minor
      Found in src/integrations/stripe/routes.js - About 2 hrs to fix

        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':
        Severity: Major
        Found in src/services/base-operator-date-parser.js - About 2 hrs to fix

          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,
          Severity: Minor
          Found in src/services/smart-action-field-validator.js - About 2 hrs to fix

          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];
          Severity: Major
          Found in src/integrations/stripe/serializers/subscriptions.js - About 2 hrs to fix

            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];
            Severity: Major
            Found in src/integrations/layer/setup.js - About 2 hrs to fix

              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;
              Severity: Major
              Found in src/integrations/layer/serializers/conversations.js - About 2 hrs to fix

                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];
                Severity: Minor
                Found in src/integrations/stripe/serializers/invoices.js - About 2 hrs to fix

                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) {
                Severity: Major
                Found in src/serializers/resource.js - About 2 hrs to fix

                  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': {
                  Severity: Minor
                  Found in src/services/base-operator-date-parser.js - About 2 hrs to fix

                    Function prettyPrint has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const prettyPrint = (json, indentation = '') => {
                      let result = '';
                    
                      if (_.isArray(json)) {
                        result += '[';
                    Severity: Minor
                    Found in src/utils/json.js - About 1 hr to fix

                      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(),
                      Severity: Minor
                      Found in src/routes/resources.js - About 1 hr to fix

                        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
                        Severity: Minor
                        Found in src/integrations/intercom/setup.js - About 1 hr to fix

                          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;
                            }
                          Severity: Minor
                          Found in src/index.js - About 1 hr to fix

                            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),
                            Severity: Minor
                            Found in src/integrations/index.js - About 1 hr to fix

                            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'],
                            Severity: Minor
                            Found in src/integrations/stripe/setup.js - About 1 hr to fix

                              Function perform has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                this.perform = () => {
                                  const {
                                    collection: collectionModel,
                                    field: collectionFieldName,
                                    embeddedPath,
                              Severity: Minor
                              Found in src/integrations/stripe/services/sources-getter.js - About 1 hr to fix

                                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, []];
                                        }
                                Severity: Minor
                                Found in src/integrations/intercom/services/conversations-getter.js - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language