ForestAdmin/forest-express

View on GitHub

Showing 124 of 261 total issues

Function InvoicesGetter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function InvoicesGetter(Implementation, params, opts, integrationInfo) {
  const stripe = opts.integrations.stripe.stripe(opts.integrations.stripe.apiKey);
  let collectionModel = null;

  function hasPagination() {
Severity: Minor
Found in src/integrations/stripe/services/invoices-getter.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 SubscriptionsGetter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function SubscriptionsGetter(Implementation, params, opts, integrationInfo) {
  const stripe = opts.integrations.stripe.stripe(opts.integrations.stripe.apiKey);
  let collectionModel = null;

  function hasPagination() {
Severity: Minor
Found in src/integrations/stripe/services/subscriptions-getter.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 doesTriggerCustomActionRequiresApproval has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private async doesTriggerCustomActionRequiresApproval(
    userId: string | number,
    customActionName: string,
    collectionName: string,
    filterForCaller: GenericPlainTree,
Severity: Minor
Found in src/services/authorization/action-authorization.ts - About 1 hr to fix

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

      this.perform = () => {
        if (integrationInfo) {
          app.get(
            path.generate(`${modelName}_closeio_leads/:leadId`, opts),
            auth.ensureAuthenticated,
    Severity: Minor
    Found in src/integrations/close.io/routes.js - About 1 hr to fix

      Function validateField has 26 lines of code (exceeds 25 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 1 hr to fix

        Function assertCanTriggerCustomAction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public async assertCanTriggerCustomAction({
            user: { id: userId },
            collectionName,
            customActionName,
            filterForCaller,
        Severity: Minor
        Found in src/services/authorization/action-authorization.ts - About 1 hr to fix

          Function ResourceSerializer has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            Implementation,
            model,
            records,
            integrator,
            meta,
          Severity: Major
          Found in src/serializers/resource.js - About 1 hr to fix

            Function handleResult has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              handleResult(result) {
                if (!result) return;
            
                if ([200, 202, 204].includes(result.status)) {
                  if (result.body && result.body.warning) {
            Severity: Minor
            Found in src/services/apimap-sender.js - About 55 mins 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 serializeConversations has a Cognitive Complexity of 9 (exceeds 5 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: Minor
            Found in src/integrations/layer/serializers/conversations.js - About 55 mins 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 AttributesGetter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function AttributesGetter(Implementation, params, opts, mappingValue) {
              const Intercom = opts.integrations.intercom.intercom;
              const intercom = new Intercom.Client(opts.integrations.intercom.credentials);
            
              this.perform = async () => {
            Severity: Minor
            Found in src/integrations/intercom/services/attributes-getter.js - About 55 mins 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 prettyPrint has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const prettyPrint = (json, indentation = '') => {
              let result = '';
            
              if (_.isArray(json)) {
                result += '[';
            Severity: Minor
            Found in src/utils/json.js - About 55 mins 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 IpWhitelistDeserializer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function IpWhitelistDeserializer(data) {
              this.perform = () =>
                P.try(() => ({
                  useIpWhitelist: data.attributes.use_ip_whitelist,
                  rules: data.attributes.rules.map((rule) => {
            Severity: Minor
            Found in src/deserializers/ip-whitelist.js - About 45 mins 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 exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            module.exports = function Associations(app, model, Implementation, integrator, opts) {
            Severity: Minor
            Found in src/routes/associations.js - About 35 mins to fix

              Function SmartFieldsValuesInjector has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                record,
                modelName,
                fieldsPerModel,
                depth = 0,
                requestedField = null,
              Severity: Minor
              Found in src/services/smart-fields-values-injector.js - About 35 mins to fix

                Function ResourceDeserializer has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function ResourceDeserializer(Implementation, model, params, withRelationships, opts) {
                Severity: Minor
                Found in src/deserializers/resource.js - About 35 mins to fix

                  Function authenticationCallback has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  async function authenticationCallback(context, options, request, response, next) {
                  Severity: Minor
                  Found in src/routes/authentication.js - About 35 mins to fix

                    Function ConversationsGetter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function ConversationsGetter(Implementation, params, opts, mappingValue) {
                      const Intercom = opts.integrations.intercom.intercom;
                      const intercom = new Intercom.Client(opts.integrations.intercom.credentials);
                    
                      function hasPagination() {
                    Severity: Minor
                    Found in src/integrations/intercom/services/conversations-getter.js - About 35 mins 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 sort has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      sort(apimap) {
                        try {
                          apimap = ApimapSorter._reorderKeysBasic(apimap);
                          apimap.data = ApimapSorter._sortArrayOfObjects(apimap.data);
                    
                    
                    Severity: Minor
                    Found in src/services/apimap-sorter.js - About 35 mins 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

                    Avoid too many return statements within this function.
                    Open

                            return reject(new VError(error, 'Forest server request error'));
                    Severity: Major
                    Found in src/services/forest-server-requester.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return reject(new Error(errorMessages.SERVER_TRANSACTION.UNEXPECTED, error));
                      Severity: Major
                      Found in src/services/forest-server-requester.js - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language