bcgov/common-forms-toolkit

View on GitHub

Showing 559 of 559 total issues

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

  async updateSubmission (req, res, next) {
    try {
      const response = await this._dataService.updateSubmission(req.params.submissionId, req.body, req.currentUser);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in docs/sample/forms/myform/controller.js and 2 other locations - About 2 hrs to fix
app/src/forms/attestations/controller.js on lines 93..100
app/src/forms/common/controller.js on lines 103..110

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

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 statusQuery(params) {
    try {
      const response = await this.axios.get(
        `${this.apiV1}/status`,
        {
Severity: Major
Found in app/src/components/chesService.js and 1 other location - About 2 hrs to fix
app/src/components/chesService.js on lines 71..86

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

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 cancelQuery(params) {
    try {
      const response = await this.axios.delete(
        `${this.apiV1}/cancel`,
        {
Severity: Major
Found in app/src/components/chesService.js and 1 other location - About 2 hrs to fix
app/src/components/chesService.js on lines 38..53

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

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 updateSubmission (req, res, next) {
    try {
      const response = await this._dataService.updateSubmission(req.params.submissionId, req.body, req.currentUser);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/attestations/controller.js and 2 other locations - About 2 hrs to fix
app/src/forms/common/controller.js on lines 103..110
docs/sample/forms/myform/controller.js on lines 76..83

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

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 createSubmissionNote(req, res, next) {
    try {
      const response = await this._dataService.createSubmissionNote(req.body, req.params.submissionId, req.currentUser);
      res.status(201).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/common/controller.js and 1 other location - About 2 hrs to fix
app/src/forms/common/controller.js on lines 39..46

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

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

exports.up = function(knex) {
  return knex(`${PREFIX}_settings`).del()
    .then(() => {
      const data = {
        name: 'submissionEmail',
Severity: Major
Found in app/src/db/migrations/20200519164226_006-settings-table-data.js - About 2 hrs to fix

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

    exports.up = function(knex) {
      return Promise.resolve()
        .then(() => knex.schema.createTable(`${PREFIX}_form`, table => {
          table.uuid('formId').references('formId').inTable('form').notNullable().primary();
          table.string('description');
    Severity: Major
    Found in app/src/db/migrations/20210506111301_018-farmopscreening-common.js - About 2 hrs to fix

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

      exports.up = function(knex) {
        return Promise.resolve()
          .then(() => knex.schema.createTable(`${PREFIX}_form`, table => {
            table.uuid('formId').references('formId').inTable('form').notNullable().primary();
            table.string('description');

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

        exports.up = function(knex) {
          return Promise.resolve()
            .then(() => knex.schema.createTable(`${PREFIX}_form`, table => {
              table.uuid('formId').references('formId').inTable('form').notNullable().primary();
              table.string('description');

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

                const submissions = await this._models.SubmissionSearchView.query()
                  .modify('filterVersion', params.version)
                  .modify('filterConfirmationId', params.confirmationId)
                  .modify('filterBusinessName', params.business)
                  .modify('filterCity', params.city)
          Severity: Major
          Found in app/src/forms/attestations/dataService.js and 1 other location - About 2 hrs to fix
          app/src/forms/attestations/dataService.js on lines 369..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 86.

          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.SubmissionSearchView.query()
                  .modify('filterVersion', params.version)
                  .modify('filterConfirmationId', params.confirmationId)
                  .modify('filterBusinessName', params.business)
                  .modify('filterCity', params.city)
          Severity: Major
          Found in app/src/forms/attestations/dataService.js and 1 other location - About 2 hrs to fix
          app/src/forms/attestations/dataService.js on lines 439..445

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

          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

            async updateUserRoles(req, res, next) {
              try {
                const response = await this._service.updateUserRoles(req.params.userId, req.body);
                res.status(200).json(response);
              } catch (error) {
          Severity: Major
          Found in app/src/forms/teammanagement/controller.js and 3 other locations - About 2 hrs to fix
          app/src/forms/attestations/controller.js on lines 102..109
          app/src/forms/teammanagement/controller.js on lines 88..95
          docs/sample/forms/myform/controller.js on lines 85..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 85.

          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

            async deleteSubmission (req, res, next) {
              try {
                const response = await this._dataService.deleteSubmission(req.params.submissionId, req.currentUser);
                res.status(200).json(response);
              } catch (error) {
          Severity: Major
          Found in app/src/forms/attestations/controller.js and 3 other locations - About 2 hrs to fix
          app/src/forms/teammanagement/controller.js on lines 50..57
          app/src/forms/teammanagement/controller.js on lines 88..95
          docs/sample/forms/myform/controller.js on lines 85..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 85.

          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

            async deleteSubmission (req, res, next) {
              try {
                const response = await this._dataService.deleteSubmission(req.params.submissionId, req.currentUser);
                res.status(200).json(response);
              } catch (error) {
          Severity: Major
          Found in docs/sample/forms/myform/controller.js and 3 other locations - About 2 hrs to fix
          app/src/forms/attestations/controller.js on lines 102..109
          app/src/forms/teammanagement/controller.js on lines 50..57
          app/src/forms/teammanagement/controller.js on lines 88..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 85.

          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

            async updateRoleUsers(req, res, next) {
              try {
                const response = await this._service.updateRoleUsers(req.params.roleId, req.body);
                res.status(200).json(response);
              } catch (error) {
          Severity: Major
          Found in app/src/forms/teammanagement/controller.js and 3 other locations - About 2 hrs to fix
          app/src/forms/attestations/controller.js on lines 102..109
          app/src/forms/teammanagement/controller.js on lines 50..57
          docs/sample/forms/myform/controller.js on lines 85..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 85.

          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 62 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 docs/sample/db/migrations/20200626145742_myform-data.js - About 2 hrs to fix

            Function init has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function init(config, watch, options) {
              const ctor = sanitizeConfig(config);
              const keycloak = Keycloak(ctor);
            
              watch.$once('ready', function (cb) {
            Severity: Major
            Found in app/frontend/src/plugins/keycloak.js - About 2 hrs to fix

              Function relationMappings has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static get relationMappings() {
                  return {
                    attestation: {
                      relation: Model.HasOneRelation,
                      modelClass: this.Attestation,
              Severity: Major
              Found in app/src/forms/attestations/models/submission.js - About 2 hrs to fix

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

                  async createSubmission(req, res, next) {
                    try {
                      const response = await this._dataService.createSubmission(req.body, req.currentUser);
                      res.status(201).json(response);
                    } catch (error) {
                Severity: Major
                Found in docs/sample/forms/myform/controller.js and 4 other locations - About 2 hrs to fix
                app/src/forms/attestations/controller.js on lines 24..31
                app/src/forms/common/controller.js on lines 85..92
                app/src/forms/common/controller.js on lines 94..101
                docs/sample/forms/myform/controller.js on lines 22..29

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                  async updateCurrentStatusCodes(req, res, next) {
                    try {
                      const response = await this._dataService.updateCurrentStatusCodes(req.body, req.currentUser);
                      res.status(201).json(response);
                    } catch (error) {
                Severity: Major
                Found in app/src/forms/common/controller.js and 4 other locations - About 2 hrs to fix
                app/src/forms/attestations/controller.js on lines 24..31
                app/src/forms/common/controller.js on lines 94..101
                docs/sample/forms/myform/controller.js on lines 22..29
                docs/sample/forms/myform/controller.js on lines 58..65

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

                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