bcgov/common-forms-toolkit

View on GitHub

Showing 559 of 559 total issues

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

    this._routes.get('/current/statusCodes', middleware.publicRateLimiter, async (req, res, next) => {
      await this._controller.readCurrentStatusCodes(req, res, next);
    });
Severity: Major
Found in app/src/forms/common/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/attestations/router.js on lines 59..61
app/src/forms/common/router.js on lines 15..17
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 docs/sample/forms/myform/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/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

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('/current', middleware.publicRateLimiter, async (req, res, next) => {
      await this._controller.current(req, res, next);
    });
Severity: Major
Found in app/src/forms/common/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/attestations/router.js on lines 59..61
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

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

const getCurrentUserFromRequest = req => {
  try {
    return getCurrentUserFromToken(req.kauth.grant.access_token);
  } catch (err) {
    return DEFAULT_USER;
Severity: Minor
Found in app/src/forms/common/middleware/auth.js and 1 other location - About 40 mins to fix
app/src/forms/common/middleware/auth.js on lines 34..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 2 locations. Consider refactoring.
Open

const getComfortResourcesFromRequest = req => {
  try {
    return getComfortResourcesFromToken(req.kauth.grant.access_token);
  } catch (err) {
    return DEFAULT_RESOURCES;
Severity: Minor
Found in app/src/forms/common/middleware/auth.js and 1 other location - About 40 mins to fix
app/src/forms/common/middleware/auth.js on lines 26..32

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

    try {
      Model.knex(this.knex);
      log.verbose('DataConnection.checkModel', 'Database models ok');
      return true;
    } catch (err) {
Severity: Minor
Found in app/src/db/dataConnection.js and 1 other location - About 40 mins to fix
app/src/db/dataConnection.js on lines 91..103

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

    try {
      return Promise
        .all(tables.map(table => this._knex.schema.hasTable(table)))
        .then(exists => exists.every(x => x))
        .then(result => {
Severity: Minor
Found in app/src/db/dataConnection.js and 1 other location - About 40 mins to fix
app/src/db/dataConnection.js on lines 112..120

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

Function assertOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function assertOptions(options) {
  const { config, init, onReady, onInitError } = options;
  if (typeof config !== 'string' && !_isObject(config)) {
    return { hasError: true, error: `'config' option must be a string or an object. Found: '${config}'` };
  }
Severity: Minor
Found in app/frontend/src/plugins/keycloak.js - About 35 mins 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 hasResourceRoles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    hasResourceRoles: (_state, getters) => (resource, roles) => {
      if (!getters.authenticated) return false;
      if (!roles.length) return true; // No roles to check against

      if (getters.resourceAccess && getters.resourceAccess[resource]) {
Severity: Minor
Found in app/frontend/src/store/modules/auth.js - About 35 mins 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

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

class Status extends CommonModels.Status {
  static get tablePrefix() {
    return PREFIX;
  }

app/src/forms/attestations/agriseafoodopscreening/models/form.js on lines 58..70
app/src/forms/attestations/farmopscreening/models/form.js on lines 58..70
app/src/forms/attestations/forestrysectoroperatorscreening/models/form.js on lines 58..70
docs/sample/forms/myform/models/form.js on lines 58..70

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

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

Avoid too many return statements within this function.
Open

  return {
    hasError: false,
    error: null
  };
Severity: Major
Found in app/frontend/src/plugins/keycloak.js - About 30 mins to fix

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

    class Status extends CommonModels.Status {
      static get tablePrefix() {
        return PREFIX;
      }
    
    
    Severity: Major
    Found in docs/sample/forms/myform/models/form.js and 4 other locations - About 30 mins to fix
    app/src/forms/attestations/agriseafoodopscreening/models/form.js on lines 58..70
    app/src/forms/attestations/farmopscreening/models/form.js on lines 58..70
    app/src/forms/attestations/forestrysectoroperatorscreening/models/form.js on lines 58..70
    app/src/forms/attestations/minesoperatorscreening/models/form.js on lines 58..70

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

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

    class Status extends CommonModels.Status {
      static get tablePrefix() {
        return PREFIX;
      }
    
    
    app/src/forms/attestations/farmopscreening/models/form.js on lines 58..70
    app/src/forms/attestations/forestrysectoroperatorscreening/models/form.js on lines 58..70
    app/src/forms/attestations/minesoperatorscreening/models/form.js on lines 58..70
    docs/sample/forms/myform/models/form.js on lines 58..70

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

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

    class Status extends CommonModels.Status {
      static get tablePrefix() {
        return PREFIX;
      }
    
    
    app/src/forms/attestations/agriseafoodopscreening/models/form.js on lines 58..70
    app/src/forms/attestations/farmopscreening/models/form.js on lines 58..70
    app/src/forms/attestations/minesoperatorscreening/models/form.js on lines 58..70
    docs/sample/forms/myform/models/form.js on lines 58..70

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

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

    class Status extends CommonModels.Status {
      static get tablePrefix() {
        return PREFIX;
      }
    
    
    Severity: Major
    Found in app/src/forms/attestations/farmopscreening/models/form.js and 4 other locations - About 30 mins to fix
    app/src/forms/attestations/agriseafoodopscreening/models/form.js on lines 58..70
    app/src/forms/attestations/forestrysectoroperatorscreening/models/form.js on lines 58..70
    app/src/forms/attestations/minesoperatorscreening/models/form.js on lines 58..70
    docs/sample/forms/myform/models/form.js on lines 58..70

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

    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

          const { data, status } = await this.axios.get(url, {
            headers: {
              'Content-Type': 'application/json'
            }
          });
    Severity: Minor
    Found in app/src/components/cdogsService.js and 1 other location - About 30 mins to fix
    app/src/components/cdogsService.js on lines 30..34

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

    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

          const { data, status } = await this.axios.get(url, {
            headers: {
              'Content-Type': 'application/json'
            }
          });
    Severity: Minor
    Found in app/src/components/cdogsService.js and 1 other location - About 30 mins to fix
    app/src/components/cdogsService.js on lines 80..84

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

    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 sendSubmissionEmail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      async sendSubmissionEmail(submission, to) {
        try {
          const settings = await this._dataService.readSettings('submissionEmail');
          if (settings && settings.enabled) {
            if (!this._submissionEmailBody) {
    Severity: Minor
    Found in app/src/forms/attestations/emailService.js - About 25 mins 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 sendConfirmationEmail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      async sendConfirmationEmail(submission) {
        try {
          const settings = await this._dataService.readSettings('confirmationEmail');
          if (settings && settings.enabled) {
            if (!this._confirmationEmailBody) {
    Severity: Minor
    Found in app/src/forms/attestations/emailService.js - About 25 mins 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

    Severity
    Category
    Status
    Source
    Language