bcgov/common-forms-toolkit

View on GitHub

Showing 559 of 559 total issues

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

  async read(req, res, next){
    try {
      const response = await this._dataService.read();
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in docs/sample/forms/myform/controller.js and 4 other locations - About 1 hr to fix
app/src/forms/attestations/controller.js on lines 33..40
app/src/forms/attestations/controller.js on lines 42..49
app/src/forms/common/controller.js on lines 11..18
docs/sample/forms/myform/controller.js on lines 40..47

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

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 jsonSchema() {
    return {
      type: 'object',
      required: Object.keys(AttestationSchema.properties).map(x => x),
      properties: {
Severity: Major
Found in app/src/forms/attestations/models/submission.js and 1 other location - About 1 hr to fix
app/src/forms/attestations/models/submission.js on lines 391..401

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

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 jsonSchema() {
    return {
      type: 'object',
      required: Object.keys(AttestationTransportationSchema.properties).map(x => x),
      properties: {
Severity: Major
Found in app/src/forms/attestations/models/submission.js and 1 other location - About 1 hr to fix
app/src/forms/attestations/models/submission.js on lines 365..375

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

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

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

    Function down has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function down has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.down = function(knex) {
        return Promise.resolve()
          .then(() => {
            return knex(`${PREFIX}_settings`).del();
          })
      Severity: Minor
      Found in app/src/db/migrations/20210506111303_020-farmopscreening-data.js - About 1 hr to fix

        Function down has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

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

            async _getSubmissionEmailContexts(settings, submission, to) {
              const result = await super._getSubmissionEmailContexts(settings, submission, to);
              result.every(x => x.context.operationType = submission.operationType.display);
              return result;
            }
          Severity: Major
          Found in app/src/forms/attestations/emailService.js and 1 other location - About 1 hr to fix
          app/src/forms/attestations/emailService.js on lines 209..213

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

          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 _getStatusAssignmentEmailContexts(settings, submission, statusUpdate) {
              const result = await super._getStatusAssignmentEmailContexts(settings, submission, statusUpdate);
              result.every(x => x.context.operationType = submission.operationType.display);
              return result;
            }
          Severity: Major
          Found in app/src/forms/attestations/emailService.js and 1 other location - About 1 hr to fix
          app/src/forms/attestations/emailService.js on lines 197..201

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

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

            async update(obj, user) {
              if (!obj) {
                throw Error(`${this._constants.TITLE} cannot be updated without data`);
              }
          
          
          Severity: Minor
          Found in app/src/forms/attestations/dataService.js - About 1 hr to fix

            Function update has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async update(obj, user) {
                if (!obj) {
                  throw Error(`${this._constants.TITLE} cannot be updated without data`);
                }
            
            
            Severity: Minor
            Found in docs/sample/forms/myform/dataService.js - About 1 hr to fix

              Function create has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async create(obj, user) {
                  if (!obj) {
                    throw Error(`${this._constants.TITLE} cannot be created without data`);
                  }
              
              
              Severity: Minor
              Found in app/src/forms/attestations/dataService.js - About 1 hr to fix

                Function create has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async create(obj, user) {
                    if (!obj) {
                      throw Error(`${this._constants.TITLE} cannot be created without data`);
                    }
                
                
                Severity: Minor
                Found in docs/sample/forms/myform/dataService.js - About 1 hr to fix

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

                    async _findClient(id) {
                      const result = await this._kcAdminClient.clients.findOne({ id: id });
                      if (!result) {
                        this._notFoundProblem('client', id);
                      }
                  Severity: Major
                  Found in app/src/components/keycloakAdminService.js and 2 other locations - About 1 hr to fix
                  app/src/components/keycloakAdminService.js on lines 153..159
                  app/src/components/keycloakAdminService.js on lines 161..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 64.

                  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

                    async _findUser(id) {
                      const result = await this._kcAdminClient.users.findOne({ id: id });
                      if (!result) {
                        this._notFoundProblem('user', id);
                      }
                  Severity: Major
                  Found in app/src/components/keycloakAdminService.js and 2 other locations - About 1 hr to fix
                  app/src/components/keycloakAdminService.js on lines 145..151
                  app/src/components/keycloakAdminService.js on lines 153..159

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

                  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

                    async _findRole(id) {
                      const result = await this._kcAdminClient.roles.findOneById({ id: id });
                      if (!result) {
                        this._notFoundProblem('role', id);
                      }
                  Severity: Major
                  Found in app/src/components/keycloakAdminService.js and 2 other locations - About 1 hr to fix
                  app/src/components/keycloakAdminService.js on lines 145..151
                  app/src/components/keycloakAdminService.js on lines 161..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 64.

                  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

                    async read() {
                      return this._models.Form.query()
                        .first()
                        .allowGraph('[versions.statusCodes, metadata]')
                        .withGraphFetched('metadata')
                  Severity: Major
                  Found in app/src/forms/attestations/dataService.js and 1 other location - About 1 hr to fix
                  docs/sample/forms/myform/dataService.js on lines 164..171

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

                  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

                    async read() {
                      return this._models.Form.query()
                        .first()
                        .allowGraph('[versions.statusCodes, metadata]')
                        .withGraphFetched('metadata')
                  Severity: Major
                  Found in docs/sample/forms/myform/dataService.js and 1 other location - About 1 hr to fix
                  app/src/forms/attestations/dataService.js on lines 164..171

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

                  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

                    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")
                  as
                  app/src/db/migrations/20210506111304-021-farmopscreening_submission_search_vw.js on lines 4..47

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

                  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

                    return Promise.resolve()
                      .then(() => knex.schema.raw(`create view ${FARM_PREFIX}_submission_search_vw
                              ("submissionId", "createdAt", deleted, "formVersionId", "confirmationId", "operationType", "assignedTo",
                               "statusCode", "statusDate", name, city, "operationTypeDisplay", "statusDisplay")
                  as
                  app/src/db/migrations/20200804105455-015-attestation_submission_search_vws.js on lines 6..49

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

                  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