bcgov/common-forms-toolkit

View on GitHub
app/src/forms/common/controller.js

Summary

Maintainability
F
3 days
Test Coverage

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

  async allSettings(req, res, next){
    try {
      const enabled = ['true','false'].includes(req.query.enabled) ? req.query.enabled === 'true' : undefined;
      const response = await this._dataService.allSettings(enabled);
      res.status(200).json(response);
Severity: Major
Found in app/src/forms/common/controller.js and 2 other locations - About 4 hrs to fix
app/src/forms/attestations/controller.js on lines 128..136
app/src/forms/common/controller.js on lines 75..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 116.

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 readCurrentStatusCodes(req, res, next) {
    try {
      const enabled = ['true','false'].includes(req.query.enabled) ? req.query.enabled === 'true' : undefined;
      const response = await this._dataService.readCurrentStatusCodes(enabled);
      res.status(200).json(response);
Severity: Major
Found in app/src/forms/common/controller.js and 2 other locations - About 4 hrs to fix
app/src/forms/attestations/controller.js on lines 128..136
app/src/forms/common/controller.js on lines 121..129

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

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 updateSettings (req, res, next) {
    try {
      const response = await this._dataService.updateSettings(req.params.name, req.body, req.currentUser);
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/common/controller.js and 2 other locations - About 2 hrs to fix
app/src/forms/attestations/controller.js on lines 93..100
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 createSubmissionStatusNote(req, res, next){
    try {
      const response = await this._dataService.createSubmissionStatusNote(req.body, req.params.statusId, 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 57..64

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

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

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

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

  async current(req, res, next) {
    try {
      const response = await this._dataService.current();
      res.status(200).json(response);
    } catch (error) {
Severity: Major
Found in app/src/forms/common/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
docs/sample/forms/myform/controller.js on lines 31..38
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

There are no issues that match your filters.

Category
Status