bcgov/common-hosted-email-service

View on GitHub

Showing 117 of 117 total issues

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

      if (integrityList && integrityList.length) {
        log.error(`Message(s) ${integrityList} inconsistent or corrupted.`, { function: 'findPromoteMessages' });
        throw new Problem(500, {
          detail: 'Some message(s) are inconsistent or corrupted.',
          messages: integrityList
Severity: Major
Found in app/src/services/chesSvc.js and 1 other location - About 1 hr to fix
app/src/services/chesSvc.js on lines 177..183

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

export default function (data) {
  console.log(`VU: ${__VU}  -  ITER: ${__ITER}`);
  console.debug('Running Tests');
  console.debug(`Data from setup: ${JSON.stringify(data)}`);
  if (!data.token) {
Severity: Minor
Found in load-tests/script.js - About 1 hr to fix

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

      return Promise.resolve()
        .then(() => knex.schema.alterTable('message', table => {
          table.dropForeign('transactionId');
          table.foreign('transactionId').references('transactionId').inTable('trxn');
        }))
    Severity: Major
    Found in app/src/services/migrations/20240229000000_cascade.js and 2 other locations - About 1 hr to fix
    app/src/services/migrations/20240229000000_cascade.js on lines 18..26
    app/src/services/migrations/20240229000000_cascade.js on lines 18..30

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

    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

      resume() {
        if (this.queue) {
          this.queue.resume(true).then(() => {
            log.info('Start accepting new jobs', { function: 'resume' });
          });
    Severity: Major
    Found in app/src/services/queueConn.js and 1 other location - About 1 hr to fix
    app/src/services/queueConn.js on lines 196..202

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

    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

      pause() {
        if (this.queue) {
          this.queue.pause(true).then(() => {
            log.info('Stop accepting new jobs', { function: 'pause' });
          });
    Severity: Major
    Found in app/src/services/queueConn.js and 1 other location - About 1 hr to fix
    app/src/services/queueConn.js on lines 208..214

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

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

    exports.up = function (knex) {
    
      const statusTable = (table) => {
        table.uuid('messageId').references('messageId').inTable('message').notNullable().index();
        table.string('status').notNullable().defaultTo('accepted');
    Severity: Minor
    Found in app/src/services/migrations/20191016164716_init.js - About 1 hr to fix

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

                if (!models.context.tag(c['tag'])) {
                  errors.push({ value: c['tag'], message: `Contexts[${i}] invalid value \`tag\`.` });
                }
      Severity: Major
      Found in app/src/components/validators.js and 4 other locations - About 1 hr to fix
      app/src/components/validators.js on lines 315..317
      app/src/components/validators.js on lines 318..320
      app/src/components/validators.js on lines 321..323
      app/src/components/validators.js on lines 327..329

      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

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

                if (!models.context.to(c['to'])) {
                  errors.push({ value: c['to'], message: `Contexts[${i}] invalid value \`to\`.` });
                }
      Severity: Major
      Found in app/src/components/validators.js and 4 other locations - About 1 hr to fix
      app/src/components/validators.js on lines 318..320
      app/src/components/validators.js on lines 321..323
      app/src/components/validators.js on lines 324..326
      app/src/components/validators.js on lines 327..329

      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

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

                if (!models.context.bcc(c['bcc'])) {
                  errors.push({ value: c['bcc'], message: `Contexts[${i}] invalid value \`bcc\`.` });
                }
      Severity: Major
      Found in app/src/components/validators.js and 4 other locations - About 1 hr to fix
      app/src/components/validators.js on lines 315..317
      app/src/components/validators.js on lines 318..320
      app/src/components/validators.js on lines 324..326
      app/src/components/validators.js on lines 327..329

      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

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

                if (!models.context.cc(c['cc'])) {
                  errors.push({ value: c['cc'], message: `Contexts[${i}] invalid value \`cc\`.` });
                }
      Severity: Major
      Found in app/src/components/validators.js and 4 other locations - About 1 hr to fix
      app/src/components/validators.js on lines 315..317
      app/src/components/validators.js on lines 321..323
      app/src/components/validators.js on lines 324..326
      app/src/components/validators.js on lines 327..329

      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

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

                if (!models.context.delayTS(c['delayTS'])) {
                  errors.push({ value: c['delayTS'], message: `Contexts[${i}] invalid value \`delayTS\`.` });
                }
      Severity: Major
      Found in app/src/components/validators.js and 4 other locations - About 1 hr to fix
      app/src/components/validators.js on lines 315..317
      app/src/components/validators.js on lines 318..320
      app/src/components/validators.js on lines 321..323
      app/src/components/validators.js on lines 324..326

      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

      Function relationMappings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static relationMappings () {
          const Queue = require('./queue');
          const Status = require('./status');
          const Trxn = require('./trxn');
          return {
      Severity: Minor
      Found in app/src/services/models/message.js - About 1 hr to fix

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

        process.on('unhandledRejection', err => {
          log.error(`Unhandled Rejection: ${err.message ?? err}`, { function: 'onUnhandledRejection' });
          fatalErrorHandler();
        });
        Severity: Major
        Found in app/app.js and 1 other location - About 1 hr to fix
        app/app.js on lines 131..134

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

        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

        process.on('uncaughtException', err => {
          log.error(`Unhandled Exception: ${err.message ?? err}`, { function: 'onUncaughtException' });
          fatalErrorHandler();
        });
        Severity: Major
        Found in app/app.js and 1 other location - About 1 hr to fix
        app/app.js on lines 127..130

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

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

          async sendEmailMerge(client, template, ethereal = false) {
            if (!template) {
              throw new Problem(400, { detail: 'Error sending email merge. Email templates/contexts cannot be null' });
            }
            if (!ethereal && !client) {
        Severity: Minor
        Found in app/src/services/chesSvc.js - About 1 hr to fix

          Function cancelMessage has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async cancelMessage(client, messageId) {
              if (!client || !messageId) {
                throw new Problem(400, { detail: 'Error cancelling message. Client and messageId cannot be null' });
              }
          
          
          Severity: Minor
          Found in app/src/services/chesSvc.js - About 1 hr to fix

            Function updateStatus has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async updateStatus(client, messageId, status, description) {
                let trx;
                try {
                  trx = await Message.startTransaction();
            
            
            Severity: Minor
            Found in app/src/services/dataSvc.js - About 1 hr to fix

              Function setup has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function setup() {
                console.log(`Email url: ${emailUrl}`);
                console.log(`SSO url: ${oidcUrl}`);
                console.debug('Getting Token');
                // Check a secret was supplied or nothing will work
              Severity: Minor
              Found in load-tests/script.js - About 1 hr to fix

                Function promoteMessage has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async promoteMessage(client, messageId) {
                    if (!client || !messageId) {
                      throw new Problem(400, { detail: 'Error promoting message. Client and messageId cannot be null' });
                    }
                
                
                Severity: Minor
                Found in app/src/services/chesSvc.js - About 1 hr to fix

                  Function _createClient has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const _createClient = () => {
                    let redis;
                  
                    const redisOpts = {
                      enableReadyCheck: false, // Bull forcibly assumes Redis is ready if it has connected to it
                  Severity: Minor
                  Found in app/src/services/queueConn.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language