bcgov/nr-get-token

View on GitHub

Showing 143 of 143 total issues

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

acronymsRouter.get('/:acronym/history', async (req, res) => {
  // Check for required permissions. Can only fetch details for the acronyms you are associated with
  const permissionErr = await permissionHelpers.checkAcronymPermission(
    req.kauth.grant.access_token.content.sub,
    req.params.acronym
Severity: Major
Found in app/src/routes/v1/acronyms.js and 1 other location - About 1 day to fix
app/src/routes/v1/acronyms.js on lines 35..56

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

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

acronymsRouter.get('/:acronym/clients', async (req, res) => {
  // Check for required permissions. Can only fetch details for the acronyms you are associated with
  const permissionErr = await permissionHelpers.checkAcronymPermission(
    req.kauth.grant.access_token.content.sub,
    req.params.acronym
Severity: Major
Found in app/src/routes/v1/acronyms.js and 1 other location - About 1 day to fix
app/src/routes/v1/acronyms.js on lines 59..80

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

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

usersRouter.get('/:keycloakId/acronyms/clients', [
  param('keycloakId', 'Must be a valid UUID')
    .custom(value => validator.isUUID(value))
], async (req, res) => {
  // TODO: Move this into middleware or equivalent
Severity: Major
Found in app/src/routes/v1/users.js and 1 other location - About 7 hrs to fix
app/src/routes/v1/users.js on lines 9..29

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

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

usersRouter.get('/:keycloakId/acronyms', [
  param('keycloakId', 'Must be a valid UUID')
    .custom(value => validator.isUUID(value))
], async (req, res) => {
  // TODO: Move this into middleware or equivalent
Severity: Major
Found in app/src/routes/v1/users.js and 1 other location - About 7 hrs to fix
app/src/routes/v1/users.js on lines 32..52

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

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

  async getServiceAccountUser(id) {
    if (!id) {
      log.error('id parameter is null.', { function: 'getServiceAccountUser' });
      throw new Error(
        'Cannot get client service account user: id parameter cannot be null.'
Severity: Major
Found in app/src/components/realmAdminSvc.js and 3 other locations - About 4 hrs to fix
app/src/components/realmAdminSvc.js on lines 58..70
app/src/components/realmAdminSvc.js on lines 230..243
app/src/components/realmAdminSvc.js on lines 285..298

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

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

  async getClientRoles(id) {
    if (!id) {
      log.error('id parameter is null.', { function: 'getClientRoles' });
      throw new Error('Cannot get client roles: id parameter cannot be null.');
    }
Severity: Major
Found in app/src/components/realmAdminSvc.js and 3 other locations - About 4 hrs to fix
app/src/components/realmAdminSvc.js on lines 58..70
app/src/components/realmAdminSvc.js on lines 230..243
app/src/components/realmAdminSvc.js on lines 268..283

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

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

  async getClient(id) {
    if (!id) {
      log.error('id parameter is null.', { function: 'getClient' });
      throw new Error('Cannot get client: id parameter cannot be null.');
    }
Severity: Major
Found in app/src/components/realmAdminSvc.js and 3 other locations - About 4 hrs to fix
app/src/components/realmAdminSvc.js on lines 230..243
app/src/components/realmAdminSvc.js on lines 268..283
app/src/components/realmAdminSvc.js on lines 285..298

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

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

  async getClientSecret(id) {
    if (!id) {
      log.error('id parameter is null.', { function: 'getClientSecret' });
      throw new Error('Cannot get client secret: id parameter cannot be null.');
    }
Severity: Major
Found in app/src/components/realmAdminSvc.js and 3 other locations - About 4 hrs to fix
app/src/components/realmAdminSvc.js on lines 58..70
app/src/components/realmAdminSvc.js on lines 268..283
app/src/components/realmAdminSvc.js on lines 285..298

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

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 createClient has 114 lines of code (exceeds 40 allowed). Consider refactoring.
Open

  async createClient(clientId, name, description) {
    if (!clientId || !name || !description) {
      log.error('A parameter is null.', { function: 'createClient' });
      throw new Error(
        'Cannot create client: clientId, name, and description cannot be null.'
Severity: Major
Found in app/src/components/realmAdminSvc.js - About 3 hrs to fix

    Function manage has 107 lines of code (exceeds 40 allowed). Consider refactoring.
    Open

      async manage({
        applicationAcronym,
        applicationName,
        applicationDescription,
        commonServices,
    Severity: Major
    Found in app/src/components/keyCloakServiceClientMgr.js - About 3 hrs to fix

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

          async getAcronymClientStatus(context) {
            try {
              const subject = context.rootGetters['auth/keycloakSubject'];
              const response = await UserService.getServiceClients(subject);
              context.commit('setAcronymClientStatus', response.data);
      Severity: Major
      Found in app/frontend/src/store/modules/user.js and 1 other location - About 2 hrs to fix
      app/frontend/src/store/modules/user.js on lines 65..74

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

      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

          async getUserAcronyms(context) {
            try {
              const subject = context.rootGetters['auth/keycloakSubject'];
              const response = await UserService.getUserAcronyms(subject);
              context.commit('setAcronyms', response.data);
      Severity: Major
      Found in app/frontend/src/store/modules/user.js and 1 other location - About 2 hrs to fix
      app/frontend/src/store/modules/user.js on lines 50..59

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

      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 init has 60 lines of code (exceeds 40 allowed). Consider refactoring.
      Open

      function init(config, watch, options) {
        const ctor = sanitizeConfig(config);
        const keycloak = Keycloak(ctor);
      
        watch.$once('ready', function (cb) {
      Severity: Major
      Found in app/frontend/src/plugins/keycloak.js - About 1 hr to fix

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

          getServiceClientHistory(acronym) {
            if (acronym) {
              return getokAxios().get(`${ApiRoutes.ACRONYMS}/${acronym}/history`, { timeout: 30000 });
            } else {
              return Promise.reject('No acronym supplied');
        Severity: Major
        Found in app/frontend/src/services/acronymService.js and 1 other location - About 1 hr to fix
        app/frontend/src/services/acronymService.js on lines 35..41

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

        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

          getServiceClients(acronym) {
            if (acronym) {
              return getokAxios().get(`${ApiRoutes.ACRONYMS}/${acronym}/clients`, { timeout: 30000 });
            } else {
              return Promise.reject('No acronym supplied');
        Severity: Major
        Found in app/frontend/src/services/acronymService.js and 1 other location - About 1 hr to fix
        app/frontend/src/services/acronymService.js on lines 49..55

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

        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

          Acronym.associate = (model) => {
            Acronym.belongsToMany(model.User, {
              foreignKey: 'acronymId',
              through: model.UserAcronym
            });
        Severity: Major
        Found in app/src/models/acronym.js and 1 other location - About 1 hr to fix
        app/src/models/user.js on lines 35..43

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

        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

          User.associate = (model) => {
            User.belongsToMany(model.Acronym, {
              foreignKey: 'userId',
              through: model.UserAcronym
            });
        Severity: Major
        Found in app/src/models/user.js and 1 other location - About 1 hr to fix
        app/src/models/acronym.js on lines 40..48

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

        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 install has 55 lines of code (exceeds 40 allowed). Consider refactoring.
        Open

          install: function (Vue, params = {}) {
            if (installed) return;
            installed = true;
        
            const defaultParams = {
        Severity: Major
        Found in app/frontend/src/plugins/keycloak.js - About 1 hr to fix

          Function manage has a Cognitive Complexity of 14 (exceeds 6 allowed). Consider refactoring.
          Open

            async manage({
              applicationAcronym,
              applicationName,
              applicationDescription,
              commonServices,
          Severity: Minor
          Found in app/src/components/keyCloakServiceClientMgr.js - About 1 hr 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 getUsers has 52 lines of code (exceeds 40 allowed). Consider refactoring.
          Open

            getUsers: async (applicationAcronym) => {
              if (!applicationAcronym) {
                const errMsg = 'No app acronym supplied to getUsers';
                log.error(errMsg, { function: 'getUsers' });
                throw new Error(errMsg);
          Severity: Major
          Found in app/src/components/acronyms.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language