ForestAdmin/forest-express

View on GitHub

Showing 255 of 261 total issues

Similar blocks of code found in 2 locations. 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 and 1 other location - About 3 days to fix
src/integrations/stripe/services/invoices-getter.js on lines 5..92

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

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 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 and 1 other location - About 3 days to fix
src/integrations/stripe/services/subscriptions-getter.js on lines 5..92

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

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

    fields: [
      { field: 'id', type: 'String', isFilterable: false },
      { field: 'amount_due', type: 'Number', isFilterable: false },
      { field: 'attempt_count', type: 'Number', isFilterable: false },
      { field: 'attempted', type: 'Boolean', isFilterable: false },
Severity: Major
Found in src/integrations/stripe/setup.js and 1 other location - About 1 day to fix
src/integrations/stripe/setup.js on lines 93..115

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

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

    fields: [
      { field: 'id', type: 'String', isFilterable: false },
      { field: 'last4', type: 'String', isFilterable: false },
      { field: 'brand', type: 'String', isFilterable: false },
      { field: 'funding', type: 'String', isFilterable: false },
Severity: Major
Found in src/integrations/stripe/setup.js and 1 other location - About 1 day to fix
src/integrations/stripe/setup.js on lines 57..79

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

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 PaymentsGetter(Implementation, params, opts, integrationInfo) {
  const stripe = opts.integrations.stripe.stripe(opts.integrations.stripe.apiKey);
  let collectionModel = null;

  function getCharge(paymentId) {
Severity: Major
Found in src/integrations/stripe/services/payment-getter.js and 1 other location - About 1 day to fix
src/integrations/stripe/services/invoice-getter.js on lines 3..36

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

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 InvoicesGetter(Implementation, params, opts, integrationInfo) {
  const stripe = opts.integrations.stripe.stripe(opts.integrations.stripe.apiKey);
  let collectionModel = null;

  function getInvoice(invoiceId) {
Severity: Major
Found in src/integrations/stripe/services/invoice-getter.js and 1 other location - About 1 day to fix
src/integrations/stripe/services/payment-getter.js on lines 3..36

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

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

module.exports = function Routes(app, model, Implementation, opts) {
  const { modelsManager } = inject();
  const modelName = Implementation.getModelName(model);
  let integrationInfo;

Severity: Major
Found in src/integrations/stripe/routes.js - About 1 day to fix

    Function ResourceSerializer has 176 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function ResourceSerializer(
      Implementation,
      model,
      records,
      integrator,
    Severity: Major
    Found in src/serializers/resource.js - About 7 hrs to fix

      Function Associations has 171 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function Associations(app, model, Implementation, integrator, opts) {
        const { modelsManager } = inject();
        const modelName = Implementation.getModelName(model);
        const schema = Schemas.schemas[modelName];
      
      
      Severity: Major
      Found in src/routes/associations.js - About 6 hrs to fix

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

          function update(request, response, next) {
            const params = _.extend(request.params, getAssociation(request));
            const data = request.body;
            const models = modelsManager.getModels();
            const associationField = getAssociationField(params.associationName);
        Severity: Major
        Found in src/routes/associations.js and 1 other location - About 6 hrs to fix
        src/routes/associations.js on lines 100..120

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

        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 add(request, response, next) {
            const params = _.extend(request.params, getAssociation(request));
            const data = request.body;
            const models = modelsManager.getModels();
            const associationField = getAssociationField(params.associationName);
        Severity: Major
        Found in src/routes/associations.js and 1 other location - About 6 hrs to fix
        src/routes/associations.js on lines 156..176

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

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

        exports.createCollections = (Implementation, apimap, collectionAndFieldName) => {
          // jshint camelcase: false
          const { modelsManager } = inject();
          const model = modelsManager.getModels()[collectionAndFieldName.split('.')[0]];
          const modelName = Implementation.getModelName(model);
        Severity: Major
        Found in src/integrations/stripe/setup.js - About 6 hrs to fix

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

            function isMappingValid() {
              const models = modelsManager.getModels();
              let mappingValid = true;
              _.map(options.integrations.mixpanel.mapping, (mappingValue) => {
                const collectionName = mappingValue.split('.')[0];
          Severity: Major
          Found in src/integrations/mixpanel/index.js and 3 other locations - About 6 hrs to fix
          src/integrations/close.io/index.js on lines 20..37
          src/integrations/intercom/index.js on lines 20..37
          src/integrations/layer/index.js on lines 19..36

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

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

            function isMappingValid() {
              const models = modelsManager.getModels();
              let mappingValid = true;
              _.map(opts.integrations.layer.mapping, (mappingValue) => {
                const collectionName = mappingValue.split('.')[0];
          Severity: Major
          Found in src/integrations/layer/index.js and 3 other locations - About 6 hrs to fix
          src/integrations/close.io/index.js on lines 20..37
          src/integrations/intercom/index.js on lines 20..37
          src/integrations/mixpanel/index.js on lines 22..39

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

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

            function isMappingValid() {
              const models = modelsManager.getModels();
              let mappingValid = true;
              _.map(opts.integrations.closeio.mapping, (mappingValue) => {
                const collectionName = mappingValue.split('.')[0];
          Severity: Major
          Found in src/integrations/close.io/index.js and 3 other locations - About 6 hrs to fix
          src/integrations/intercom/index.js on lines 20..37
          src/integrations/layer/index.js on lines 19..36
          src/integrations/mixpanel/index.js on lines 22..39

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

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

            function isMappingValid() {
              const models = modelsManager.getModels();
              let mappingValid = true;
              _.map(opts.integrations.intercom.mapping, (mappingValue) => {
                const collectionName = mappingValue.split('.')[0];
          Severity: Major
          Found in src/integrations/intercom/index.js and 3 other locations - About 6 hrs to fix
          src/integrations/close.io/index.js on lines 20..37
          src/integrations/layer/index.js on lines 19..36
          src/integrations/mixpanel/index.js on lines 22..39

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

          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

                apimap.data = apimap.data.map((collection) => {
                  collection = ApimapSorter._reorderKeysChild(collection);
                  collection.attributes = ApimapSorter._reorderKeysCollection(collection.attributes);
                  if (collection.attributes.fields) {
                    collection.attributes.fields = ApimapSorter._sortArrayOfFields(
          Severity: Major
          Found in src/services/apimap-sorter.js and 1 other location - About 6 hrs to fix
          src/services/apimap-sorter.js on lines 86..95

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

          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

                  apimap.included = apimap.included.map((include) => {
                    include = ApimapSorter._reorderKeysChild(include);
                    include.attributes = ApimapSorter._reorderKeysCollection(include.attributes);
                    if (include.attributes.fields) {
                      include.attributes.fields = ApimapSorter._sortArrayOfFields(include.attributes.fields);
          Severity: Major
          Found in src/services/apimap-sorter.js and 1 other location - About 6 hrs to fix
          src/services/apimap-sorter.js on lines 70..81

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

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

            this.perform = () => {
              const typeForAttributes = {};
          
              function getAttributesFor(dest, fields) {
                _.map(fields, (field) => {
          Severity: Major
          Found in src/serializers/resource.js - About 6 hrs to fix

            Function Stats has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function Stats(app, model, Implementation, opts) {
              const { chartHandler, modelsManager } = inject();
              const modelName = Implementation.getModelName(model);
              const permissionMiddlewareCreator = new PermissionMiddlewareCreator(modelName);
            
            
            Severity: Minor
            Found in src/routes/stats.js - About 5 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

            Severity
            Category
            Status
            Source
            Language