ForestAdmin/forest-express

View on GitHub

Showing 255 of 261 total issues

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

  if (options.integrations && options.integrations.intercom) {
    integrationInfo = new IntegrationInformationsGetter(
      modelName,
      Implementation,
      options.integrations.intercom,
Severity: Major
Found in src/integrations/intercom/routes.js and 4 other locations - About 50 mins to fix
src/integrations/close.io/routes.js on lines 19..25
src/integrations/layer/routes.js on lines 19..25
src/integrations/mixpanel/routes.js on lines 14..20
src/integrations/stripe/routes.js on lines 26..32

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

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

  if (opts.integrations && opts.integrations.stripe) {
    integrationInfo = new IntegrationInformationsGetter(
      modelName,
      Implementation,
      opts.integrations.stripe,
Severity: Major
Found in src/integrations/stripe/routes.js and 4 other locations - About 50 mins to fix
src/integrations/close.io/routes.js on lines 19..25
src/integrations/intercom/routes.js on lines 16..22
src/integrations/layer/routes.js on lines 19..25
src/integrations/mixpanel/routes.js on lines 14..20

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

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

  if (opts.integrations && opts.integrations.layer) {
    integrationInfo = new IntegrationInformationsGetter(
      modelName,
      Implementation,
      opts.integrations.layer,
Severity: Major
Found in src/integrations/layer/routes.js and 4 other locations - About 50 mins to fix
src/integrations/close.io/routes.js on lines 19..25
src/integrations/intercom/routes.js on lines 16..22
src/integrations/mixpanel/routes.js on lines 14..20
src/integrations/stripe/routes.js on lines 26..32

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

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

  if (options.integrations && options.integrations.mixpanel) {
    integrationInfo = new IntegrationInformationsGetter(
      modelName,
      Implementation,
      options.integrations.mixpanel,
Severity: Major
Found in src/integrations/mixpanel/routes.js and 4 other locations - About 50 mins to fix
src/integrations/close.io/routes.js on lines 19..25
src/integrations/intercom/routes.js on lines 16..22
src/integrations/layer/routes.js on lines 19..25
src/integrations/stripe/routes.js on lines 26..32

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

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

  if (opts.integrations && opts.integrations.closeio) {
    integrationInfo = new IntegrationInformationsGetter(
      modelName,
      Implementation,
      opts.integrations.closeio,
Severity: Major
Found in src/integrations/close.io/routes.js and 4 other locations - About 50 mins to fix
src/integrations/intercom/routes.js on lines 16..22
src/integrations/layer/routes.js on lines 19..25
src/integrations/mixpanel/routes.js on lines 14..20
src/integrations/stripe/routes.js on lines 26..32

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

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-conversations.js and 1 other location - About 50 mins to fix
src/integrations/intercom/serializers/intercom-conversation.js on lines 4..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 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

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

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

      const { query, contextVariables } = await chartHandler.getQueryForChart({
        userId: request.user.id,
        renderingId: request.user.renderingId,
        chartRequest: request.body,
      });
Severity: Minor
Found in src/routes/stats.js and 1 other location - About 40 mins to fix
src/routes/stats.js on lines 39..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 48.

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

    const chart = await chartHandler.getChartWithContextInjected({
      userId: request.user.id,
      renderingId: request.user.renderingId,
      chartRequest: request.body,
    });
Severity: Minor
Found in src/routes/stats.js and 1 other location - About 40 mins to fix
src/routes/stats.js on lines 87..91

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

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

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

              app.delete(
                path.generate(`${modelName}/:recordId`, lianaOptions),
                auth.ensureAuthenticated,
                permissionMiddlewareCreator.delete(),
                this.remove,
          Severity: Major
          Found in src/routes/resources.js and 4 other locations - About 35 mins to fix
          src/routes/resources.js on lines 166..171
          src/routes/resources.js on lines 172..177
          src/routes/resources.js on lines 184..189
          src/routes/stats.js on lines 167..167

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

          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

              app.get(
                path.generate(`${modelName}/count`, lianaOptions),
                auth.ensureAuthenticated,
                permissionMiddlewareCreator.list(),
                this.count,
          Severity: Major
          Found in src/routes/resources.js and 4 other locations - About 35 mins to fix
          src/routes/resources.js on lines 172..177
          src/routes/resources.js on lines 184..189
          src/routes/resources.js on lines 190..195
          src/routes/stats.js on lines 167..167

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

          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

              app.put(
                path.generate(`${modelName}/:recordId`, lianaOptions),
                auth.ensureAuthenticated,
                permissionMiddlewareCreator.update(),
                this.update,
          Severity: Major
          Found in src/routes/resources.js and 4 other locations - About 35 mins to fix
          src/routes/resources.js on lines 166..171
          src/routes/resources.js on lines 172..177
          src/routes/resources.js on lines 190..195
          src/routes/stats.js on lines 167..167

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

          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

              app.get(
                path.generate(`${modelName}/:recordId`, lianaOptions),
                auth.ensureAuthenticated,
                permissionMiddlewareCreator.details(),
                this.get,
          Severity: Major
          Found in src/routes/resources.js and 4 other locations - About 35 mins to fix
          src/routes/resources.js on lines 166..171
          src/routes/resources.js on lines 184..189
          src/routes/resources.js on lines 190..195
          src/routes/stats.js on lines 167..167

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

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

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

                  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 and 1 other location - About 35 mins to fix
          src/integrations/intercom/services/attributes-getter.js on lines 14..22

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

          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