ForestAdmin/forest-express

View on GitHub

Showing 255 of 261 total issues

Function SmartFieldsValuesInjector has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function SmartFieldsValuesInjector(
  record,
  modelName,
  fieldsPerModel,
  depth = 0,
Severity: Major
Found in src/services/smart-fields-values-injector.js - About 3 hrs to fix

    Function serializeSubscriptions has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    function serializeSubscriptions(subscriptions, collectionName, meta) {
      function getCustomerAttributes() {
        if (!subscriptions.length) { return []; }
    
        const schema = Schemas.schemas[collectionName];
    Severity: Minor
    Found in src/integrations/stripe/serializers/subscriptions.js - About 3 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

    File action-authorization.ts has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {
      ForestAdminClient,
    } from '@forestadmin/forestadmin-client';
    import hashObject from 'object-hash';
    import BadRequestError from '../../utils/errors/bad-request-error';
    Severity: Minor
    Found in src/services/authorization/action-authorization.ts - About 3 hrs to fix

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

        this.getAttributes = (request, response, next) => {
          new AttributesGetter(
            Implementation,
            _.extend(request.query, request.params),
            options,
      Severity: Major
      Found in src/integrations/intercom/routes.js and 1 other location - About 3 hrs to fix
      src/integrations/layer/routes.js on lines 57..70

      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 103.

      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

        this.conversation = (req, res, next) => {
          new ConversationGetter(
            Implementation,
            _.extend(req.query, req.params),
            opts,
      Severity: Major
      Found in src/integrations/layer/routes.js and 1 other location - About 3 hrs to fix
      src/integrations/intercom/routes.js on lines 24..37

      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 103.

      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 generateAndSendSchema has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function generateAndSendSchema(envSecret) {
        const collections = _.values(Schemas.schemas);
        configStore.integrator.defineCollections(collections);
      
        collections
      Severity: Major
      Found in src/index.js - About 3 hrs to fix

        Function errorHandler has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        function errorHandler({ logger } = {}) {
          /**
           * @param {any} error
           * @param {import('express').Request} request
           * @param {import('express').Response} response
        Severity: Minor
        Found in src/services/exposed/error-handler.js - About 3 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

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

          const getInvoice = (request, response, next) => {
            new InvoiceGetter(
              Implementation,
              _.extend(request.query, request.params),
              opts,
        Severity: Major
        Found in src/integrations/stripe/routes.js and 4 other locations - About 3 hrs to fix
        src/integrations/stripe/routes.js on lines 62..73
        src/integrations/stripe/routes.js on lines 138..149
        src/integrations/stripe/routes.js on lines 169..180
        src/integrations/stripe/routes.js on lines 201..207

        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 99.

        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 5 locations. Consider refactoring.
        Open

          const getCard = (request, response, next) => {
            new SourceGetter(
              Implementation,
              _.extend(request.query, request.params),
              opts,
        Severity: Major
        Found in src/integrations/stripe/routes.js and 4 other locations - About 3 hrs to fix
        src/integrations/stripe/routes.js on lines 62..73
        src/integrations/stripe/routes.js on lines 106..117
        src/integrations/stripe/routes.js on lines 169..180
        src/integrations/stripe/routes.js on lines 201..207

        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 99.

        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 5 locations. Consider refactoring.
        Open

          const getPayment = (request, response, next) => {
            new PaymentGetter(
              Implementation,
              _.extend(request.query, request.params),
              opts,
        Severity: Major
        Found in src/integrations/stripe/routes.js and 4 other locations - About 3 hrs to fix
        src/integrations/stripe/routes.js on lines 106..117
        src/integrations/stripe/routes.js on lines 138..149
        src/integrations/stripe/routes.js on lines 169..180
        src/integrations/stripe/routes.js on lines 201..207

        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 99.

        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 5 locations. Consider refactoring.
        Open

          const getBankAccount = (request, response, next) => {
            new SourceGetter(Implementation, _.extend(request.query, request.params), opts, integrationInfo)
              .perform()
              .then((bankAccount) => serializeBankAccounts(bankAccount, modelName))
              .then((bankAccount) => { response.send(bankAccount); })
        Severity: Major
        Found in src/integrations/stripe/routes.js and 4 other locations - About 3 hrs to fix
        src/integrations/stripe/routes.js on lines 62..73
        src/integrations/stripe/routes.js on lines 106..117
        src/integrations/stripe/routes.js on lines 138..149
        src/integrations/stripe/routes.js on lines 169..180

        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 99.

        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 5 locations. Consider refactoring.
        Open

          const getSubscription = (request, response, next) => {
            new SubscriptionGetter(
              Implementation,
              _.extend(request.query, request.params),
              opts,
        Severity: Major
        Found in src/integrations/stripe/routes.js and 4 other locations - About 3 hrs to fix
        src/integrations/stripe/routes.js on lines 62..73
        src/integrations/stripe/routes.js on lines 106..117
        src/integrations/stripe/routes.js on lines 138..149
        src/integrations/stripe/routes.js on lines 201..207

        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 99.

        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 ConversationsGetter has 78 lines of code (exceeds 25 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: Major
        Found in src/integrations/intercom/services/conversations-getter.js - About 3 hrs to fix

          Function SourcesGetter has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function SourcesGetter(Implementation, params, opts, integrationInfo) {
            const stripe = opts.integrations.stripe.stripe(opts.integrations.stripe.apiKey);
          
            function hasPagination() {
              return params.page;
          Severity: Major
          Found in src/integrations/stripe/services/sources-getter.js - About 3 hrs to fix

            Function PaymentsGetter has 77 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function PaymentsGetter(Implementation, params, opts, integrationInfo) {
              const stripe = opts.integrations.stripe.stripe(opts.integrations.stripe.apiKey);
              let collectionModel = null;
            
              function hasPagination() {
            Severity: Major
            Found in src/integrations/stripe/services/payments-getter.js - About 3 hrs to fix

              Function SubscriptionsGetter has 76 lines of code (exceeds 25 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: Major
              Found in src/integrations/stripe/services/subscriptions-getter.js - About 3 hrs to fix

                Function InvoicesGetter has 76 lines of code (exceeds 25 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: Major
                Found in src/integrations/stripe/services/invoices-getter.js - About 3 hrs to fix

                  Function getWithLiveQuery has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    this.getWithLiveQuery = async (request, response, next) => {
                      try {
                        const { query, contextVariables } = await chartHandler.getQueryForChart({
                          userId: request.user.id,
                          renderingId: request.user.renderingId,
                  Severity: Major
                  Found in src/routes/stats.js - About 2 hrs to fix

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

                      this.perform = () => {
                        if (integrationInfo) {
                          app.get(
                            path.generate(`${modelName}_stripe_payments`, opts),
                            auth.ensureAuthenticated,
                    Severity: Major
                    Found in src/integrations/stripe/routes.js - About 2 hrs to fix

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

                          return new P(((resolve, reject) => request
                            .get(`https://api.layer.com/apps/${opts.integrations.layer.appId
                            }/conversations/${params.conversationId}`)
                            .set('Accept', 'application/vnd.layer+json; version=2.0')
                            .set('Content-type', 'application/json')
                      Severity: Major
                      Found in src/integrations/layer/services/conversation-getter.js and 1 other location - About 2 hrs to fix
                      src/integrations/layer/services/messages-getter.js on lines 6..16

                      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 91.

                      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