bcgov/common-forms-toolkit

View on GitHub

Showing 88 of 559 total issues

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

    Function verifyBoolean has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const verifyBoolean = (obj, param, result, errors) => {
      if (obj[param]) {
        if (isBoolean(obj[param])) {
          result[param] = obj[param];
        } else if (isString(obj[param]) && ['true','false'].includes(obj[param].toLowerCase())) {
    Severity: Minor
    Found in app/src/forms/form/middleware/searchParameters.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 updateSubmission has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      async updateSubmission(submissionId, obj, user) {
        // update: location, contacts, business
        if (!obj) {
          throw Error(`${this._constants.TITLE} Submission cannot be updated without data`);
        }
    Severity: Minor
    Found in docs/sample/forms/myform/dataService.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

    Function createSubmissionStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      async createSubmissionStatus(obj, submissionId, user) {
        if (!obj) {
          throw Error('Status cannot be created without data');
        }
    
    
    Severity: Minor
    Found in app/src/forms/common/dataService.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 submissionSearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const submissionSearch = (models) => {
      return (req, res, next) => {
        try {
          const errors = [];
          const result = new models.SubmissionSearch();
    Severity: Minor
    Found in app/src/forms/attestations/middleware/searchParameters.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 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 verifyBoolean has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const verifyBoolean = (obj, param, result, errors) => {
      if (obj[param]) {
        if (isBoolean(obj[param])) {
          result[param] = obj[param];
        } else if (isString(obj[param]) && ['true', 'false'].includes(obj[param].toLowerCase())) {
    Severity: Minor
    Found in app/src/forms/attestations/middleware/searchParameters.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