ForestAdmin/forest-express

View on GitHub

Showing 255 of 261 total issues

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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              function isProperlyIntegrated() {
                return opts.integrations.intercom.accessToken
                  && opts.integrations.intercom.intercom && opts.integrations.intercom.mapping;
              }
            Severity: Major
            Found in src/integrations/intercom/index.js and 1 other location - About 1 hr to fix
            src/integrations/close.io/index.js on lines 15..18

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 55.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              function isProperlyIntegrated() {
                return opts.integrations.closeio.apiKey && opts.integrations.closeio.closeio
                  && opts.integrations.closeio.mapping;
              }
            Severity: Major
            Found in src/integrations/close.io/index.js and 1 other location - About 1 hr to fix
            src/integrations/intercom/index.js on lines 15..18

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 55.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  _.each(collection.segments, (segment) => {
                    segment.id = `${collection.name}.${segment.name}`;
                  });
            Severity: Minor
            Found in src/serializers/schema.js and 1 other location - About 55 mins to fix
            src/serializers/schema.js on lines 103..105

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 54.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  _.each(collection.actions, (action) => {
                    action.id = `${collection.name}.${action.name}`;
                  });
            Severity: Minor
            Found in src/serializers/schema.js and 1 other location - About 55 mins to fix
            src/serializers/schema.js on lines 107..109

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 54.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (_.isArray(conversations)) {
                data = conversations.map((conversation) => mapConversation(conversation));
              } else {
                data = mapConversation(conversations);
              }
            Severity: Minor
            Found in src/integrations/layer/serializers/conversations.js and 1 other location - About 55 mins to fix
            src/integrations/layer/serializers/messages.js on lines 17..21

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 53.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  try {
                    const loadedFields = await this.smartActionHookService.getResponse(
                      action,
                      action.hooks.load,
                      action.fields,
            Severity: Minor
            Found in src/routes/actions.js and 1 other location - About 55 mins to fix
            src/routes/actions.js on lines 55..73

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 53.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  try {
                    const data = this.smartActionHookDeserializer.deserialize(request.body);
            
                    const { fields, changedField } = data;
                    const fieldChanged = fields.find((field) => field.field === changedField);
            Severity: Minor
            Found in src/routes/actions.js and 1 other location - About 55 mins to fix
            src/routes/actions.js on lines 31..43

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 53.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (_.isArray(messages)) {
                data = messages.map((message) => mapMessage(message));
              } else {
                data = mapMessage(messages);
              }
            Severity: Minor
            Found in src/integrations/layer/serializers/messages.js and 1 other location - About 55 mins to fix
            src/integrations/layer/serializers/conversations.js on lines 30..34

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 53.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            class UnprocessableEntity extends Error {
              constructor(message) {
                super(message);
                this.name = 'UnprocessableEntity';
                this.status = 422;
            Severity: Minor
            Found in src/utils/error.js and 1 other location - About 50 mins to fix
            src/utils/error.js on lines 3..10

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 52.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            class Unauthorized extends Error {
              constructor(message) {
                super(message);
                this.name = 'Unauthorized';
                this.status = 401;
            Severity: Minor
            Found in src/utils/error.js and 1 other location - About 50 mins to fix
            src/utils/error.js on lines 12..19

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 52.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

              if (conversation.conversation_message) {
                // NOTICE: Intercom API old version
                conversation.subject = conversation.conversation_message.subject;
                conversation.body = [conversation.conversation_message.body, conversation.link];
              } else {
            Severity: Minor
            Found in src/integrations/intercom/serializers/intercom-conversation.js and 1 other location - About 50 mins to fix
            src/integrations/intercom/serializers/intercom-conversations.js on lines 5..15

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 51.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language