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 createSettings(req, res, next){
    try {
      const response = await this._dataService.createSettings(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 85..92
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

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

  async readSubmissionPublic(req, res, next){
    try {
      const response = await this._dataService.readSubmission(req.params.submissionId, true);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/attestations/controller.js and 1 other location - About 2 hrs to fix
docs/sample/forms/myform/controller.js on lines 67..74

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 update(req, res, next){
    try {
      const response = await this._dataService.update(req.body, req.currentUser);
      res.status(200).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 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

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

  async update(req, res, next){
    try {
      const response = await this._dataService.update(req.body, req.currentUser);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/attestations/controller.js and 4 other locations - About 2 hrs to fix
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
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

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

const verifyString = (obj, param, result, errors) => {
  if (obj[param]) {
    if (isString(obj[param])) {
      result[param] = obj[param];
    } else {
Severity: Major
Found in app/src/forms/form/middleware/searchParameters.js and 1 other location - About 2 hrs to fix
app/src/forms/attestations/middleware/searchParameters.js on lines 20..28

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

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

  async readSubmissionPublic(req, res, next){
    try {
      const response = await this._dataService.readSubmission(req.params.submissionId, true);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in docs/sample/forms/myform/controller.js and 1 other location - About 2 hrs to fix
app/src/forms/attestations/controller.js on lines 71..78

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

const verifyString = (obj, param, result, errors) => {
  if (obj[param]) {
    if (isString(obj[param])) {
      result[param] = obj[param];
    } else {
Severity: Major
Found in app/src/forms/attestations/middleware/searchParameters.js and 1 other location - About 2 hrs to fix
app/src/forms/form/middleware/searchParameters.js on lines 12..20

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

  async readSubmissionStatuses(req, res, next){
    try {
      const response = await this._dataService.readSubmissionStatuses(req.params.submissionId);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/common/controller.js and 5 other locations - About 2 hrs to fix
app/src/forms/common/controller.js on lines 48..55
app/src/forms/common/controller.js on lines 66..73
app/src/forms/common/controller.js on lines 112..119
app/src/forms/teammanagement/controller.js on lines 41..48
app/src/forms/teammanagement/controller.js on lines 79..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 80.

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

  async readUserRoles(req, res, next) {
    try {
      const result = await this._service.getUserRoles(req.params.userId);
      res.status(200).json(result);
    } catch (error) {
Severity: Major
Found in app/src/forms/teammanagement/controller.js and 5 other locations - About 2 hrs to fix
app/src/forms/common/controller.js on lines 30..37
app/src/forms/common/controller.js on lines 48..55
app/src/forms/common/controller.js on lines 66..73
app/src/forms/common/controller.js on lines 112..119
app/src/forms/teammanagement/controller.js on lines 79..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 80.

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

  async readRoleUsers(req, res, next) {
    try {
      const result = await this._service.getRoleUsers(req.params.roleId);
      res.status(200).json(result);
    } catch (error) {
Severity: Major
Found in app/src/forms/teammanagement/controller.js and 5 other locations - About 2 hrs to fix
app/src/forms/common/controller.js on lines 30..37
app/src/forms/common/controller.js on lines 48..55
app/src/forms/common/controller.js on lines 66..73
app/src/forms/common/controller.js on lines 112..119
app/src/forms/teammanagement/controller.js on lines 41..48

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

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

  async readSettings(req, res, next) {
    try {
      const response = await this._dataService.readSettings(req.params.name);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/common/controller.js and 5 other locations - About 2 hrs to fix
app/src/forms/common/controller.js on lines 30..37
app/src/forms/common/controller.js on lines 48..55
app/src/forms/common/controller.js on lines 66..73
app/src/forms/teammanagement/controller.js on lines 41..48
app/src/forms/teammanagement/controller.js on lines 79..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 80.

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 currentSubmission = await this._models.Submission.query()
        .first()
        .where({submissionId: submissionId})
        .where({submissionId: obj.submissionId})
        .withGraphFetched('[business, contacts, location]')
Severity: Major
Found in app/src/forms/attestations/dataService.js and 1 other location - About 2 hrs to fix
docs/sample/forms/myform/dataService.js on lines 281..286

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

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

  async readSubmissionStatusNotes (req, res, next){
    try {
      const response = await this._dataService.readSubmissionStatusNotes(req.params.statusId);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/common/controller.js and 5 other locations - About 2 hrs to fix
app/src/forms/common/controller.js on lines 30..37
app/src/forms/common/controller.js on lines 66..73
app/src/forms/common/controller.js on lines 112..119
app/src/forms/teammanagement/controller.js on lines 41..48
app/src/forms/teammanagement/controller.js on lines 79..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 80.

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

  async readSubmissionNotes(req, res, next) {
    try {
      const response = await this._dataService.readSubmissionNotes(req.params.submissionId);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/common/controller.js and 5 other locations - About 2 hrs to fix
app/src/forms/common/controller.js on lines 30..37
app/src/forms/common/controller.js on lines 48..55
app/src/forms/common/controller.js on lines 112..119
app/src/forms/teammanagement/controller.js on lines 41..48
app/src/forms/teammanagement/controller.js on lines 79..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 80.

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 currentSubmission = await this._models.Submission.query()
        .first()
        .where({submissionId: submissionId})
        .where({submissionId: obj.submissionId})
        .withGraphFetched('[survey]')
Severity: Major
Found in docs/sample/forms/myform/dataService.js and 1 other location - About 2 hrs to fix
app/src/forms/attestations/dataService.js on lines 287..292

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

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 56 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 docs/sample/db/migrations/20200626145729_myform-common.js - About 2 hrs to fix

    File minesOperatorScreeningForm.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import moment from 'moment';
    
    import commonFormService from '@/services/commonFormService';
    import { FormNames } from '@/utils/constants';
    import { SampleData, RandomCities } from './sampleData.js';

      Function install has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        install: function (Vue, params = {}) {
          if (installed) return;
          installed = true;
      
          const defaultParams = {
      Severity: Major
      Found in app/frontend/src/plugins/keycloak.js - About 2 hrs to fix

        File agriSeafoodOpScreeningForm.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import moment from 'moment';
        
        import commonFormService from '@/services/commonFormService';
        import { FormNames } from '@/utils/constants';
        import { SampleData, RandomCities } from './sampleData.js';

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

          exports.up = function (knex) {
            return Promise.resolve()
              .then(() => knex.schema.alterTable(`${AGRI_PREFIX}_submission_location`, table => {
                table.dropColumn('licencees');
              }));
          app/src/db/migrations/20210604111302_022-farmopscreening-form_updates.js on lines 10..15

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

          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