bcgov/common-forms-toolkit

View on GitHub
app/src/forms/attestations/router.js

Summary

Maintainability
C
1 day
Test Coverage
A
100%

Function constructor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor(slug, controller, models) {
    this._resourceAccess = `comfort-${slug}`;
    this._controller = controller;
    this._models = models;
    this._routes = require('express').Router();
Severity: Minor
Found in app/src/forms/attestations/router.js - About 1 hr to fix

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

        this._routes.put('/submissions/:submissionId', middleware.hasRole(this._resourceAccess, ['editor']), async (req, res, next) => {
          await this._controller.updateSubmission(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 17 other locations - About 1 hr to fix
    app/src/forms/attestations/router.js on lines 14..16
    app/src/forms/attestations/router.js on lines 18..20
    app/src/forms/attestations/router.js on lines 34..36
    app/src/forms/common/router.js on lines 27..29
    app/src/forms/common/router.js on lines 31..33
    app/src/forms/common/router.js on lines 35..37
    app/src/forms/common/router.js on lines 39..41
    app/src/forms/common/router.js on lines 43..45
    app/src/forms/common/router.js on lines 47..49
    app/src/forms/common/router.js on lines 51..53
    app/src/forms/common/router.js on lines 55..57
    app/src/forms/common/router.js on lines 59..61
    docs/sample/forms/myform/router.js on lines 14..16
    docs/sample/forms/myform/router.js on lines 18..20
    docs/sample/forms/myform/router.js on lines 22..24
    docs/sample/forms/myform/router.js on lines 30..32
    docs/sample/forms/myform/router.js on lines 34..36

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

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

        this._routes.put('/current', middleware.hasRole(this._resourceAccess, ['admin']), async (req, res, next) => {
          await this._controller.update(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 17 other locations - About 1 hr to fix
    app/src/forms/attestations/router.js on lines 14..16
    app/src/forms/attestations/router.js on lines 30..32
    app/src/forms/attestations/router.js on lines 34..36
    app/src/forms/common/router.js on lines 27..29
    app/src/forms/common/router.js on lines 31..33
    app/src/forms/common/router.js on lines 35..37
    app/src/forms/common/router.js on lines 39..41
    app/src/forms/common/router.js on lines 43..45
    app/src/forms/common/router.js on lines 47..49
    app/src/forms/common/router.js on lines 51..53
    app/src/forms/common/router.js on lines 55..57
    app/src/forms/common/router.js on lines 59..61
    docs/sample/forms/myform/router.js on lines 14..16
    docs/sample/forms/myform/router.js on lines 18..20
    docs/sample/forms/myform/router.js on lines 22..24
    docs/sample/forms/myform/router.js on lines 30..32
    docs/sample/forms/myform/router.js on lines 34..36

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

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

        this._routes.post('/', middleware.hasRole(this._resourceAccess, ['admin']), async (req, res, next) => {
          await this._controller.create(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 17 other locations - About 1 hr to fix
    app/src/forms/attestations/router.js on lines 18..20
    app/src/forms/attestations/router.js on lines 30..32
    app/src/forms/attestations/router.js on lines 34..36
    app/src/forms/common/router.js on lines 27..29
    app/src/forms/common/router.js on lines 31..33
    app/src/forms/common/router.js on lines 35..37
    app/src/forms/common/router.js on lines 39..41
    app/src/forms/common/router.js on lines 43..45
    app/src/forms/common/router.js on lines 47..49
    app/src/forms/common/router.js on lines 51..53
    app/src/forms/common/router.js on lines 55..57
    app/src/forms/common/router.js on lines 59..61
    docs/sample/forms/myform/router.js on lines 14..16
    docs/sample/forms/myform/router.js on lines 18..20
    docs/sample/forms/myform/router.js on lines 22..24
    docs/sample/forms/myform/router.js on lines 30..32
    docs/sample/forms/myform/router.js on lines 34..36

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

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

        this._routes.delete('/submissions/:submissionId', middleware.hasRole(this._resourceAccess, ['editor']), async (req, res, next) => {
          await this._controller.deleteSubmission(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 17 other locations - About 1 hr to fix
    app/src/forms/attestations/router.js on lines 14..16
    app/src/forms/attestations/router.js on lines 18..20
    app/src/forms/attestations/router.js on lines 30..32
    app/src/forms/common/router.js on lines 27..29
    app/src/forms/common/router.js on lines 31..33
    app/src/forms/common/router.js on lines 35..37
    app/src/forms/common/router.js on lines 39..41
    app/src/forms/common/router.js on lines 43..45
    app/src/forms/common/router.js on lines 47..49
    app/src/forms/common/router.js on lines 51..53
    app/src/forms/common/router.js on lines 55..57
    app/src/forms/common/router.js on lines 59..61
    docs/sample/forms/myform/router.js on lines 14..16
    docs/sample/forms/myform/router.js on lines 18..20
    docs/sample/forms/myform/router.js on lines 22..24
    docs/sample/forms/myform/router.js on lines 30..32
    docs/sample/forms/myform/router.js on lines 34..36

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

    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

        this._routes.post('/submissions', middleware.publicRateLimiter, middleware.currentUser, async (req, res, next) => {
          await this._controller.createSubmission(req, res, next);
        });
    Severity: Minor
    Found in app/src/forms/attestations/router.js and 1 other location - About 55 mins to fix
    docs/sample/forms/myform/router.js on lines 26..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 53.

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

        this._routes.post('/submissions/email', middleware.publicRateLimiter, async (req, res, next) => {
          await this._controller.sendSubmissionEmail(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 9 other locations - About 40 mins to fix
    app/src/forms/attestations/router.js on lines 10..12
    app/src/forms/attestations/router.js on lines 38..40
    app/src/forms/attestations/router.js on lines 42..44
    app/src/forms/attestations/router.js on lines 59..61
    app/src/forms/common/router.js on lines 15..17
    app/src/forms/common/router.js on lines 19..21
    app/src/forms/teammanagement/router.js on lines 19..21
    docs/sample/forms/myform/router.js on lines 10..12
    docs/sample/forms/myform/router.js on lines 38..40

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

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

        this._routes.get('/submissions/:submissionId/pdf', middleware.publicRateLimiter, async (req, res, next) => {
          await this._controller.generateSubmissionPdf(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 9 other locations - About 40 mins to fix
    app/src/forms/attestations/router.js on lines 10..12
    app/src/forms/attestations/router.js on lines 38..40
    app/src/forms/attestations/router.js on lines 46..48
    app/src/forms/attestations/router.js on lines 59..61
    app/src/forms/common/router.js on lines 15..17
    app/src/forms/common/router.js on lines 19..21
    app/src/forms/teammanagement/router.js on lines 19..21
    docs/sample/forms/myform/router.js on lines 10..12
    docs/sample/forms/myform/router.js on lines 38..40

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

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

        this._routes.get('/types', middleware.publicRateLimiter, async (req, res, next) => {
          await this._controller.readTypes(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 9 other locations - About 40 mins to fix
    app/src/forms/attestations/router.js on lines 10..12
    app/src/forms/attestations/router.js on lines 38..40
    app/src/forms/attestations/router.js on lines 42..44
    app/src/forms/attestations/router.js on lines 46..48
    app/src/forms/common/router.js on lines 15..17
    app/src/forms/common/router.js on lines 19..21
    app/src/forms/teammanagement/router.js on lines 19..21
    docs/sample/forms/myform/router.js on lines 10..12
    docs/sample/forms/myform/router.js on lines 38..40

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

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

        this._routes.get('/', middleware.publicRateLimiter, async (req, res, next) => {
          await this._controller.read(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 9 other locations - About 40 mins to fix
    app/src/forms/attestations/router.js on lines 38..40
    app/src/forms/attestations/router.js on lines 42..44
    app/src/forms/attestations/router.js on lines 46..48
    app/src/forms/attestations/router.js on lines 59..61
    app/src/forms/common/router.js on lines 15..17
    app/src/forms/common/router.js on lines 19..21
    app/src/forms/teammanagement/router.js on lines 19..21
    docs/sample/forms/myform/router.js on lines 10..12
    docs/sample/forms/myform/router.js on lines 38..40

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

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

        this._routes.get('/submissions/:submissionId', middleware.publicRateLimiter, async (req, res, next) => {
          await this._controller.readSubmissionPublic(req, res, next);
        });
    Severity: Major
    Found in app/src/forms/attestations/router.js and 9 other locations - About 40 mins to fix
    app/src/forms/attestations/router.js on lines 10..12
    app/src/forms/attestations/router.js on lines 42..44
    app/src/forms/attestations/router.js on lines 46..48
    app/src/forms/attestations/router.js on lines 59..61
    app/src/forms/common/router.js on lines 15..17
    app/src/forms/common/router.js on lines 19..21
    app/src/forms/teammanagement/router.js on lines 19..21
    docs/sample/forms/myform/router.js on lines 10..12
    docs/sample/forms/myform/router.js on lines 38..40

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

    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