ForestAdmin/forest-express

View on GitHub

Showing 255 of 261 total issues

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

      if (
        !contactQueryResponse
        || !contactQueryResponse.body
        || !contactQueryResponse.body.data
        || !contactQueryResponse.body.data[0]
Severity: Minor
Found in src/integrations/intercom/services/attributes-getter.js and 1 other location - About 35 mins to fix
src/integrations/intercom/services/conversations-getter.js on lines 47..50

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

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

        if (fieldInfo.association && record[fieldInfo.association] && fieldInfo.name
          && record[fieldInfo.association][fieldInfo.name]) {
          record[fieldInfo.association][fieldInfo.name] = record[fieldInfo
            .association][fieldInfo.name].coordinates;
        }
Severity: Minor
Found in src/serializers/resource.js and 1 other location - About 35 mins to fix
src/serializers/resource.js on lines 120..125

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

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

  create(record) {
    return new this.Implementation.ResourceCreator(this.model, this.params, record, this.user)
      .perform();
  }
Severity: Minor
Found in src/services/exposed/record-creator.js and 1 other location - About 35 mins to fix
src/services/exposed/records-remover.js on lines 4..7

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

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

  remove(ids) {
    return new this.Implementation.ResourcesRemover(this.model, this.params, ids, this.user)
      .perform();
  }
Severity: Minor
Found in src/services/exposed/records-remover.js and 1 other location - About 35 mins to fix
src/services/exposed/record-creator.js on lines 5..8

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

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

        if (fieldInfo.association && record[fieldInfo.association] && fieldInfo.name
          && record[fieldInfo.association][fieldInfo.name]) {
          dateonly = moment.utc(record[fieldInfo.association][fieldInfo.name])
            .add(offsetServer, 'h');
          record[fieldInfo.association][fieldInfo.name] = dateonly.format();
Severity: Minor
Found in src/serializers/resource.js and 1 other location - About 35 mins to fix
src/serializers/resource.js on lines 133..137

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

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

      Avoid too many return statements within this function.
      Open

              return response.status(500).send({ error: 'Smart Action: failed to evaluate permissions' });
      Severity: Major
      Found in src/middlewares/permissions.js - About 30 mins to fix

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

                  [options.operators.GTE]: this.toDateWithTimezone(moment()
                    .subtract(value * 2, 'days').startOf('day')),
        Severity: Minor
        Found in src/services/base-operator-date-parser.js and 2 other locations - About 30 mins to fix
        src/services/base-operator-date-parser.js on lines 105..106
        src/services/base-operator-date-parser.js on lines 138..139

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

        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

              return request
                .get(`https://api.layer.com/apps/${opts.integrations.layer.appId
                }/users/${user}/conversations`)
                .set('Accept', 'application/vnd.layer+json; version=2.0')
                .set('Content-type', 'application/json')
        Severity: Minor
        Found in src/integrations/layer/services/conversations-getter.js and 1 other location - About 30 mins 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 45.

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

                  [options.operators.GTE]: this.toDateWithTimezone(moment()
                    .subtract(value - 1, 'days').startOf('day')),
        Severity: Minor
        Found in src/services/base-operator-date-parser.js and 2 other locations - About 30 mins to fix
        src/services/base-operator-date-parser.js on lines 136..137
        src/services/base-operator-date-parser.js on lines 138..139

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

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

                  [options.operators.LTE]: this.toDateWithTimezone(moment()
                    .subtract(value + 1, 'days').endOf('day')),
        Severity: Minor
        Found in src/services/base-operator-date-parser.js and 2 other locations - About 30 mins to fix
        src/services/base-operator-date-parser.js on lines 105..106
        src/services/base-operator-date-parser.js on lines 136..137

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

        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 serializeCards has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function serializeCards(cards, collectionName, meta) {
          function getCustomerAttributes() {
            if (!cards.length) { return []; }
        
            const schema = Schemas.schemas[collectionName];
        Severity: Minor
        Found in src/integrations/stripe/serializers/cards.js - About 25 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 _getSmartActionName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          _getSmartActionName(request) {
            const smartActionEndpoint = `${request.baseUrl}${request.path}`;
            const smartActionHTTPMethod = request.method;
        
            const smartAction = Schemas.schemas[this.collectionName].actions.find((action) => {
        Severity: Minor
        Found in src/middlewares/permissions.js - About 25 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 serializeBankAccounts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

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

        Severity
        Category
        Status
        Source
        Language