bcgov/common-forms-toolkit

View on GitHub

Showing 559 of 559 total issues

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

  async removeClientRoleMappings(clientId, users, roles) {
    try {
      // TEMP: refresh loop was DOSing SSO
      await this._auth();

Severity: Major
Found in app/src/components/keycloakAdminService.js and 1 other location - About 5 hrs to fix
app/src/components/keycloakAdminService.js on lines 261..273

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

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

  async addClientRoleMappings(clientId, users, roles) {
    try {
      // TEMP: refresh loop was DOSing SSO
      await this._auth();

Severity: Major
Found in app/src/components/keycloakAdminService.js and 1 other location - About 5 hrs to fix
app/src/components/keycloakAdminService.js on lines 275..287

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

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

const verifyBoolean = (obj, param, result, errors) => {
  if (obj[param]) {
    if (isBoolean(obj[param])) {
      result[param] = obj[param];
    } else if (isString(obj[param]) && ['true', 'false'].includes(obj[param].toLowerCase())) {
Severity: Major
Found in app/src/forms/attestations/middleware/searchParameters.js and 1 other location - About 5 hrs to fix
app/src/forms/form/middleware/searchParameters.js on lines 22..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 149.

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

const verifyBoolean = (obj, param, result, errors) => {
  if (obj[param]) {
    if (isBoolean(obj[param])) {
      result[param] = obj[param];
    } else if (isString(obj[param]) && ['true','false'].includes(obj[param].toLowerCase())) {
Severity: Major
Found in app/src/forms/form/middleware/searchParameters.js and 1 other location - About 5 hrs to fix
app/src/forms/attestations/middleware/searchParameters.js on lines 40..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 149.

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

exports.up = function(knex) {
  return Promise.resolve()
    .then(() => knex.schema.alterTable(`${AGRI_PREFIX}_submission_location`, table => {
      table.dropColumn('mineNumber');
      table.dropColumn('permitNumber');
Severity: Major
Found in app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js - About 5 hrs to fix

    Function up has 138 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.up = function(knex) {
      return Promise.resolve()
        .then(() => {
          return knex(`${PREFIX}_version_status_code`).del();
        })
    Severity: Major
    Found in app/src/db/migrations/20210506111303_020-farmopscreening-data.js - About 5 hrs to fix

      Function up has 138 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.up = function(knex) {
        return Promise.resolve()
          .then(() => {
            return knex(`${PREFIX}_version_status_code`).del();
          })

        Function up has 138 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.up = function(knex) {
          return Promise.resolve()
            .then(() => {
              return knex(`${PREFIX}_version_status_code`).del();
            })

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

            async readSubmission(submissionId, tiny) {
              if (tiny) {
                return this._models.Submission.query()
                  .findById(submissionId)
                  .allowGraph('[operationType, attestation, business, contacts, location]')
          Severity: Major
          Found in app/src/forms/attestations/dataService.js and 1 other location - About 5 hrs to fix
          app/src/forms/attestations/dataService.js on lines 250..268

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

          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

            async readSubmission(submissionId, tiny) {
              if (tiny) {
                return this._models.Submission.query()
                  .findById(submissionId)
                  .allowGraph('[attestation, business, contacts, location]')
          Severity: Major
          Found in app/src/forms/attestations/dataService.js and 1 other location - About 5 hrs to fix
          app/src/forms/attestations/dataService.js on lines 417..435

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

          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

            static get relationMappings () {
              return {
                notes: {
                  relation: Model.HasManyRelation,
                  modelClass: this.Note,
          Severity: Major
          Found in app/src/forms/common/models/base.js and 1 other location - About 5 hrs to fix
          app/src/forms/common/models/base.js on lines 390..409

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

          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

            static get relationMappings () {
              return {
                notes: {
                  relation: Model.HasManyRelation,
                  modelClass: this.Note,
          Severity: Major
          Found in app/src/forms/common/models/base.js and 1 other location - About 5 hrs to fix
          app/src/forms/common/models/base.js on lines 460..479

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

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

          exports.down = function(knex) {
            return Promise.resolve()
              .then(() => knex.schema.alterTable(`${AGRI_PREFIX}_submission_location`, table => {
                table.string('mineNumber').nullable();
                table.string('permitNumber').nullable();
          Severity: Major
          Found in app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js - About 5 hrs to fix

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

                  const submissions = await this._models.Submission.query()
                    .allowGraph('[operationType, attestation, business, contacts, location, statuses.[notes, statusCode], notes]')
                    .withGraphFetched('[operationType, attestation, business, location]')
                    .withGraphFetched('contacts(orderContactType)')
                    .withGraphFetched('statuses(orderDescending).[notes(orderDescending),statusCode]')
            Severity: Major
            Found in app/src/forms/attestations/dataService.js and 1 other location - About 5 hrs to fix
            app/src/forms/attestations/dataService.js on lines 378..391

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

            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 submissions = await this._models.Submission.query()
                    .allowGraph('[attestation, business, contacts, location, statuses.[notes, statusCode], notes]')
                    .withGraphFetched('[attestation, business, location]')
                    .withGraphFetched('contacts(orderContactType)')
                    .withGraphFetched('statuses(orderDescending).[notes(orderDescending),statusCode]')
            Severity: Major
            Found in app/src/forms/attestations/dataService.js and 1 other location - About 5 hrs to fix
            app/src/forms/attestations/dataService.js on lines 450..463

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

            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

            File dataService.js has 382 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const equal = require('fast-deep-equal');
            const log = require('npmlog');
            const Problem = require('api-problem');
            const {transaction} = require('objection');
            const {v4: uuidv4} = require('uuid');
            Severity: Minor
            Found in app/src/forms/attestations/dataService.js - About 5 hrs to fix

              Function up has 125 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.up = function (knex) {
                return Promise.resolve()
                  .then(() => knex.schema.raw(`create view ${AGRI_PREFIX}_submission_search_vw
                          ("submissionId", "createdAt", deleted, "formVersionId", "confirmationId", "operationType", "assignedTo",
                           "statusCode", "statusDate", name, city, "operationTypeDisplay", "statusDisplay")

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

                  return knex(`${PREFIX}_note`).del()
                    .then(() => {
                      return knex(`${PREFIX}_submission_status`).del();
                    })
                    .then(() => {
                app/src/db/migrations/20200515134601_004-minesoperatorscreening-seed-data.js on lines 14..26

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

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

                  return Promise.resolve()
                    .then(() => knex.schema.alterTable(`${AGRI_PREFIX}_submission_location`, table => {
                      table.string('mineNumber').nullable();
                      table.string('permitNumber').nullable();
                    }))
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 16..85
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 16..97
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 16..131
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 16..143
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 158..236
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 158..270
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 158..282

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

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

                  return Promise.resolve()
                    .then(() => knex.schema.alterTable(`${AGRI_PREFIX}_submission_location`, table => {
                      table.dropColumn('mineNumber');
                      table.dropColumn('permitNumber');
                    }))
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 16..97
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 16..131
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 16..143
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 158..224
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 158..236
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 158..270
                app/src/db/migrations/20200604071226_012-cleanup-data-and-model.js on lines 158..282

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

                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