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 tokenEndpoint = config.get('serviceClient.ches.tokenEndpoint');
      const username = config.get('serviceClient.ches.username');
      const password = config.get('serviceClient.ches.password');

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

    try {
      const apiEndpoint = config.get('serviceClient.ches.apiEndpoint');
      const token = await email._getChesToken();
      const response = await axios.post(
        apiEndpoint + '/v1/email',
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 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/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

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

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

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

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

    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

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

    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

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

    import { getokAxios } from '@/services/interceptors';

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

    Headers should be surrounded by blank lines
    Open

    #### Screenshots

    MD022 - Headers should be surrounded by blank lines

    Tags: headers, blank_lines

    Aliases: blanks-around-headers

    This rule is triggered when headers (any style) are either not preceded or not followed by a blank line:

    # Header 1
    Some text
    
    Some more text
    ## Header 2

    To fix this, ensure that all headers have a blank line both before and after (except where the header is at the beginning or end of the document):

    # Header 1
    
    Some text
    
    Some more text
    
    ## Header 2

    Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse headers that don't have a blank line before, and will parse them as regular text.

    Space expected between blocks
    Open

      & > .v-main {

    Empty Line Between Blocks

    Rule empty-line-between-blocks will enforce whether or not nested blocks should include a space between the last non-comment declaration or not.

    Options

    • include: true/false (defaults to true)
    • allow-single-line-rulesets: true/false (defaults to true)

    Examples

    include

    When include: true, the following are allowed. When include: false, the following are disallowed:

    .foo {
      content: 'foo';
    
      .bar {
        content: 'bar';
    
        // Waldo
        &--baz {
          content: 'baz';
        }
      }
    }

    When include: false, the following are allowed. When include: true, the following are disallowed:

    .foo {
      content: 'foo';
      .bar {
        content: 'bar';
        // Waldo
        &--baz {
          content: 'baz';
        }
      }
    }

    allow-single-line-rulesets

    When allow-single-line-rulesets: true, the following are allowed. When allow-single-line-rulesets: false, the following are disallowed:

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