bcgov/nr-get-token

View on GitHub

Showing 143 of 143 total issues

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

    try {
      const accessToken = config.get('serviceClient.github.token');
      const githubApi = config.get('serviceClient.github.apiEndpoint');

      // See https://docs.github.com/en/rest/reference/issues
Severity: Major
Found in app/src/components/github.js and 5 other locations - About 45 mins to fix
app/src/components/acronyms.js on lines 26..35
app/src/components/acronyms.js on lines 43..52
app/src/components/email.js on lines 12..28
app/src/components/email.js on lines 40..68
app/src/components/email.js on lines 83..123

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

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 {
      const apiEndpoint = config.get('serviceClient.ches.apiEndpoint');
      const token = await email._getChesToken();
      const template = fs.readFileSync(
        `${path.join(
Severity: Major
Found in app/src/components/email.js and 5 other locations - About 45 mins to fix
app/src/components/acronyms.js on lines 26..35
app/src/components/acronyms.js on lines 43..52
app/src/components/email.js on lines 12..28
app/src/components/email.js on lines 40..68
app/src/components/github.js on lines 15..38

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

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 {
      const acronymDetails = await acronymService.find(applicationAcronym);
      log.verbose('acronymDetails', { function: 'getAcronym', acronymDetails: acronymDetails });
      return acronymDetails ? acronymDetails : null;
    } catch (error) {
Severity: Major
Found in app/src/components/acronyms.js and 5 other locations - About 45 mins to fix
app/src/components/acronyms.js on lines 43..52
app/src/components/email.js on lines 12..28
app/src/components/email.js on lines 40..68
app/src/components/email.js on lines 83..123
app/src/components/github.js on lines 15..38

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

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

        queryInterface.bulkInsert('user', userData.map(entry => {
          return { ...entry, createdAt: now, updatedAt: now };
        }), { transaction: t }),
Severity: Minor
Found in app/src/seeders/20200330000000-dev-users.js and 2 other locations - About 40 mins to fix
app/src/seeders/20200330000000-dev-users.js on lines 73..75
app/src/seeders/20200330000000-dev-users.js on lines 79..81

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

        queryInterface.bulkInsert('acronym', acronymData.map(entry => {
          return { ...entry, createdAt: now, updatedAt: now };
        }), { transaction: t }),
Severity: Minor
Found in app/src/seeders/20200330000000-dev-users.js and 2 other locations - About 40 mins to fix
app/src/seeders/20200330000000-dev-users.js on lines 76..78
app/src/seeders/20200330000000-dev-users.js on lines 79..81

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

        queryInterface.bulkInsert('user_acronym', userAcronymData.map(entry => {
          return { ...entry, createdAt: now, updatedAt: now };
        }), { transaction: t })
Severity: Minor
Found in app/src/seeders/20200330000000-dev-users.js and 2 other locations - About 40 mins to fix
app/src/seeders/20200330000000-dev-users.js on lines 73..75
app/src/seeders/20200330000000-dev-users.js on lines 76..78

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

      if (response.status == 201) {
        return response.data;
      } else {
        throw new Error(
          `Error from POST to CHES /v1/email. Response Code: ${response.status}`
Severity: Minor
Found in app/src/components/email.js and 1 other location - About 35 mins to fix
app/src/components/email.js on lines 113..119

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

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

      if (response.status == 201) {
        return response.data;
      } else {
        throw new Error(
          `Error from POST to CHES /v1/emailMerge. Response Code: ${response.status}`
Severity: Minor
Found in app/src/components/email.js and 1 other location - About 35 mins to fix
app/src/components/email.js on lines 58..64

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

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

    if (response) {
      return res.status(200).json(response);
    } else {
      return new Problem(404).send(res);
    }
Severity: Minor
Found in app/src/routes/v1/acronyms.js and 2 other locations - About 30 mins to fix
app/src/routes/v1/acronyms.js on lines 133..137
app/src/routes/v1/acronyms.js on lines 151..155

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

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

        userAcronymId: {
          allowNull: false,
          defaultValue: DataTypes.UUIDV4,
          primaryKey: true,
          type: DataTypes.UUID,
    Severity: Minor
    Found in app/src/models/useracronym.js and 2 other locations - About 30 mins to fix
    app/src/models/acronym.js on lines 3..11
    app/src/models/user.js on lines 3..11

    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

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

        userId: {
          allowNull: false,
          defaultValue: DataTypes.UUIDV4,
          primaryKey: true,
          type: DataTypes.UUID,
    Severity: Minor
    Found in app/src/models/user.js and 2 other locations - About 30 mins to fix
    app/src/models/acronym.js on lines 3..11
    app/src/models/useracronym.js on lines 3..11

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

          if (response) {
            return res.status(200).json(response);
          } else {
            return new Problem(404).send(res);
          }
    Severity: Minor
    Found in app/src/routes/v1/acronyms.js and 2 other locations - About 30 mins to fix
    app/src/routes/v1/acronyms.js on lines 23..27
    app/src/routes/v1/acronyms.js on lines 151..155

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

          if (response) {
            return res.status(200).json(response);
          } else {
            return new Problem(404).send(res);
          }
    Severity: Minor
    Found in app/src/routes/v1/acronyms.js and 2 other locations - About 30 mins to fix
    app/src/routes/v1/acronyms.js on lines 23..27
    app/src/routes/v1/acronyms.js on lines 133..137

    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

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

        acronymId: {
          allowNull: false,
          defaultValue: DataTypes.UUIDV4,
          primaryKey: true,
          type: DataTypes.UUID,
    Severity: Minor
    Found in app/src/models/acronym.js and 2 other locations - About 30 mins to fix
    app/src/models/user.js on lines 3..11
    app/src/models/useracronym.js on lines 3..11

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

      async makeClientDetails(serviceClient) {
        if (serviceClient && serviceClient.id) {
          // get the service account user.
          const serviceAccountUser = await this.svc.getServiceAccountUser(
            serviceClient.id
    Severity: Minor
    Found in app/src/components/keyCloakServiceClientMgr.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

    Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
    Open

    import axios from 'axios';

    For more information visit Source: http://eslint.org/docs/rules/

    Multiline style comments should not be used
    Open

    /*

    No CSS Comments

    Rule no-css-comments will enforce the use of Sass single-line comments and disallow CSS comments. Bang comments (/*! */, will be printed even in minified mode) are still allowed.

    Examples

    When enabled the following are allowed:

    // This is a good comment
    
    // =========
    // This is a good comment
    // =========
    
    //////////////////
    // This is a good comment
    //////////////////
    
    /*! This is a good bang comment */
    
    /*!
      * This is a good bang comment
    **/

    When enabled the following are disallowed:

    /* This comment will appear in your compiled css */
    
    /*
     * Mulitline comments are bad
     */

    Selectors must be placed on new lines
    Open

    h1, h2, h3, h4, h5 {

    Single Line Per Selector

    Rule single-line-per-selector will enforce whether selectors should be placed on a new line.

    Examples

    When enabled, the following are allowed:

    .foo,
    .bar {
      content: 'baz';
    }

    When enabled, the following are disallowed:

    .foo, .bar {
      content: 'baz';
    }
    Severity
    Category
    Status
    Source
    Language