bcgov/common-forms-toolkit

View on GitHub

Showing 559 of 559 total issues

Function getRouter has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function getRouter(basePath = '/') {
  const router = new VueRouter({
    base: basePath,
    mode: 'history',
    routes: [
Severity: Minor
Found in app/frontend/src/router/index.js - About 1 hr to fix

    Function modifiers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      static get modifiers() {
        return {
          orderDescending(builder) {
            builder.orderBy('createdAt', 'desc');
          },
    Severity: Minor
    Found in app/src/forms/attestations/models/submission.js - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function modifiers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      static get modifiers() {
        return {
          orderDescending(builder) {
            builder.orderBy('createdAt', 'desc');
          },
    Severity: Minor
    Found in app/src/forms/attestations/agriseafoodopscreening/models/form.js - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function modifiers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      static get modifiers() {
        return {
          orderDescending(builder) {
            builder.orderBy('createdAt', 'desc');
          },
    Severity: Minor
    Found in app/src/forms/attestations/farmopscreening/models/form.js - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function modifiers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      static get modifiers() {
        return {
          orderDescending(builder) {
            builder.orderBy('createdAt', 'desc');
          },

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function modifiers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static get modifiers() {
        return {
          orderDescending(builder) {
            builder.orderBy('createdAt', 'desc');
          },
    Severity: Minor
    Found in app/src/forms/attestations/farmopscreening/models/form.js - About 1 hr to fix

      Function modifiers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static get modifiers() {
          return {
            orderDescending(builder) {
              builder.orderBy('createdAt', 'desc');
            },
      Severity: Minor
      Found in app/src/forms/attestations/agriseafoodopscreening/models/form.js - About 1 hr to fix

        Function modifiers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static get modifiers() {
            return {
              orderDescending(builder) {
                builder.orderBy('createdAt', 'desc');
              },
        Severity: Minor
        Found in app/src/forms/attestations/models/submission.js - About 1 hr to fix

          Function modifiers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static get modifiers() {
              return {
                orderDescending(builder) {
                  builder.orderBy('createdAt', 'desc');
                },

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

                try {
                  trx = await transaction.start(this._models.Note.knex());
            
                  obj.submissionStatusId = parseInt(statusId);
                  obj.createdBy = user.username;
            Severity: Major
            Found in app/src/forms/common/dataService.js and 5 other locations - About 1 hr to fix
            app/src/forms/common/dataService.js on lines 66..85
            app/src/forms/common/dataService.js on lines 131..145
            app/src/forms/common/dataService.js on lines 190..227
            app/src/forms/common/dataService.js on lines 235..250
            app/src/forms/common/dataService.js on lines 258..270

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

            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

                try {
            
                  trx = await transaction.start(this._models.Status.knex());
            
                  obj.submissionId = submissionId;
            Severity: Major
            Found in app/src/forms/common/dataService.js and 5 other locations - About 1 hr to fix
            app/src/forms/common/dataService.js on lines 102..116
            app/src/forms/common/dataService.js on lines 131..145
            app/src/forms/common/dataService.js on lines 190..227
            app/src/forms/common/dataService.js on lines 235..250
            app/src/forms/common/dataService.js on lines 258..270

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

            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

                try {
                  trx = await transaction.start(this._models.Settings.knex());
            
                  obj.createdBy = user.username;
                  await this._models.Settings.query().insert(obj);
            Severity: Major
            Found in app/src/forms/common/dataService.js and 5 other locations - About 1 hr to fix
            app/src/forms/common/dataService.js on lines 66..85
            app/src/forms/common/dataService.js on lines 102..116
            app/src/forms/common/dataService.js on lines 131..145
            app/src/forms/common/dataService.js on lines 190..227
            app/src/forms/common/dataService.js on lines 258..270

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

            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

                try {
                  trx = await transaction.start(this._models.Note.knex());
            
                  obj.submissionId = submissionId;
                  obj.createdBy = user.username;
            Severity: Major
            Found in app/src/forms/common/dataService.js and 5 other locations - About 1 hr to fix
            app/src/forms/common/dataService.js on lines 66..85
            app/src/forms/common/dataService.js on lines 102..116
            app/src/forms/common/dataService.js on lines 190..227
            app/src/forms/common/dataService.js on lines 235..250
            app/src/forms/common/dataService.js on lines 258..270

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

            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

                try {
                  trx = await transaction.start(this._models.StatusCode.knex());
                  // this is what we currently have, we cannot delete any status codes...
                  const currentStatusCodes = await this.readCurrentStatusCodes();
                  const currentCodes = currentStatusCodes.map(x => x.code);
            Severity: Major
            Found in app/src/forms/common/dataService.js and 5 other locations - About 1 hr to fix
            app/src/forms/common/dataService.js on lines 66..85
            app/src/forms/common/dataService.js on lines 102..116
            app/src/forms/common/dataService.js on lines 131..145
            app/src/forms/common/dataService.js on lines 235..250
            app/src/forms/common/dataService.js on lines 258..270

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

            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

                try {
                  trx = await transaction.start(this._models.Settings.knex());
                  obj.updatedBy = user.username;
                  await this._models.Settings.query(trx).patchAndFetchById(name, obj).throwIfNotFound();
                  await trx.commit();
            Severity: Major
            Found in app/src/forms/common/dataService.js and 5 other locations - About 1 hr to fix
            app/src/forms/common/dataService.js on lines 66..85
            app/src/forms/common/dataService.js on lines 102..116
            app/src/forms/common/dataService.js on lines 131..145
            app/src/forms/common/dataService.js on lines 190..227
            app/src/forms/common/dataService.js on lines 235..250

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

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

              constructor(resourceAccess) {
                super();
                this._controller = new Controller(resourceAccess);
                this._clientName = `comfort-${resourceAccess}`;
                this._routes = require('express').Router();
            Severity: Minor
            Found in app/src/forms/teammanagement/router.js - About 1 hr to fix

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

              exports.down = function(knex) {
                return knex(`${PREFIX}_note`).del()
                  .then(() => {
                    return knex(`${PREFIX}_submission_status`).del();
                  })

                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

                  Function updateCurrentStatusCodes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async updateCurrentStatusCodes (obj, user){
                      if (!obj || !Array.isArray(obj)) {
                        throw Error('Status Codes cannot be updated without data');
                      }
                      let trx;
                  Severity: Minor
                  Found in app/src/forms/common/dataService.js - About 1 hr to fix

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

                          if (!this._equalTo(currentSubmission.contacts.find(x => x.contactType === this._constants.CONTACT_TYPE_PRIMARY), primary)) {
                            primary.updatedBy = user.username;
                            await this._models.Contact.query(trx).patchAndFetchById(primary.contactId, primary);
                            doTheUpdate = true;
                          }
                    Severity: Major
                    Found in app/src/forms/attestations/dataService.js and 1 other location - About 1 hr to fix
                    app/src/forms/attestations/dataService.js on lines 309..313

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

                    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