Asymmetrik/node-rest-starter

View on GitHub

Showing 301 of 301 total issues

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

        it('should reject for non-existent user', async () => {
            await teamsService
                .getExplicitTeamIds(null)
                .should.be.rejectedWith(new InternalServerError('User does not exist'));
        });
Severity: Minor
Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 35 mins to fix
src/app/core/teams/teams.service.spec.ts on lines 1149..1155

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

Avoid too many return statements within this function.
Open

        return null;
Severity: Major
Found in src/app/common/util.service.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return Promise.reject(
                    new Error(
                        `Error retrieving entry from the access checker provider: ${ex.message}`
                    )
                );
    Severity: Major
    Found in src/app/core/access-checker/access-checker.service.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return done(null, primaryUser);
      Severity: Major
      Found in src/lib/strategies/proxy-pki.ts - About 30 mins to fix

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

                it('should return null if a nonexistent feedback ID is supplied', async () => {
                    const feedback = await feedbackService.read('123412341234123412341234');
                    should.not.exist(feedback);
                });
        Severity: Minor
        Found in src/app/core/feedback/feedback.service.spec.ts and 2 other locations - About 30 mins to fix
        src/app/core/teams/teams.service.spec.ts on lines 315..318
        src/app/core/user/user.service.spec.ts on lines 44..47

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

        function localUserSpec(key) {
            const spec = userSpec(key);
            spec.provider = 'local';
            spec.password = 'password';
            return spec;
        Severity: Minor
        Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 30 mins to fix
        src/app/core/user/auth/user-authentication.controller.spec.ts on lines 45..50

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

                it('should throw error when no provider is configured', async () => {
                    await accessChecker
                        .get('notincache')
                        .should.be.rejectedWith(
                            new Error(
        Severity: Minor
        Found in src/app/core/access-checker/access-checker.service.spec.ts and 1 other location - About 30 mins to fix
        src/app/core/feedback/feedback.service.spec.ts on lines 87..91

        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 done(null, false, err);
        Severity: Major
        Found in src/lib/strategies/proxy-pki.ts - About 30 mins to fix

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

                  it('read returns null when no team found', async () => {
                      const t = await teamsService.read('123412341234123412341234');
                      should.not.exist(t);
                  });
          Severity: Minor
          Found in src/app/core/teams/teams.service.spec.ts and 2 other locations - About 30 mins to fix
          src/app/core/feedback/feedback.service.spec.ts on lines 93..96
          src/app/core/user/user.service.spec.ts on lines 44..47

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

                  it('should throw a 404 errorResult if an invalid feedback ID is supplied', async () => {
                      await feedbackService
                          .read('1234')
                          .should.be.rejectedWith(new NotFoundError('Invalid feedback ID'));
                  });
          Severity: Minor
          Found in src/app/core/feedback/feedback.service.spec.ts and 1 other location - About 30 mins to fix
          src/app/core/access-checker/access-checker.service.spec.ts on lines 261..269

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

          function localUserSpec(key) {
              const spec = userSpec(key);
              spec.provider = 'local';
              spec.password = 'password';
              return spec;
          Severity: Minor
          Found in src/app/core/user/auth/user-authentication.controller.spec.ts and 1 other location - About 30 mins to fix
          src/app/core/teams/teams.service.spec.ts on lines 45..50

          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 done(
                          null,
                          false,
                          new UnauthorizedError(
                              'Could not authenticate request, please verify your credentials.'
          Severity: Major
          Found in src/lib/strategies/proxy-pki.ts - About 30 mins to fix

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

                    it('read returns null for invalid id', async () => {
                        const user = await userService.read('5cc9db5f738d4a7198466bc0');
                        should.not.exist(user);
                    });
            Severity: Minor
            Found in src/app/core/user/user.service.spec.ts and 2 other locations - About 30 mins to fix
            src/app/core/feedback/feedback.service.spec.ts on lines 93..96
            src/app/core/teams/teams.service.spec.ts on lines 315..318

            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 parsed;
            Severity: Major
            Found in src/app/common/util.service.ts - About 30 mins to fix

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

              export const dateParse = function (
                  // eslint-disable-next-line @typescript-eslint/ban-types
                  date: string | number | Date | Array<unknown> | Function | Object
              ) {
                  // Handle nil values, arrays, and functions by simply returning null
              Severity: Minor
              Found in src/app/common/util.service.ts - 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 verifyUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  async verifyUser(dn: string, req, isProxy = false) {
                      const dnLower = dn.toLowerCase();
              
                      const localUser = await this.userModel
                          .findOne({
              Severity: Minor
              Found in src/app/core/user/auth/user-authentication.service.ts - 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 ignorePayload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  ignorePayload(message: MessageType, messagePayload: Record<string, unknown>) {
                      // Ignore any payloads that are too old.
                      if (null != ignoreOlderThan) {
                          const messageTime = this.getMessageTime(messagePayload);
                          if (null != messageTime) {
              Severity: Minor
              Found in src/app/common/sockets/base-socket.provider.ts - 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  async get(key): Promise<Record<string, unknown>> {
                      if (null == key) {
                          return Promise.reject(new Error('key cannot be null or undefined'));
                      }
              
              
              Severity: Minor
              Found in src/app/core/access-checker/access-checker.service.ts - 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 connect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const connect = async () => {
                  // Set the mongoose debugging option based on the configuration, defaulting to false
                  const mongooseDebug = config.get('mongooseLogging');
              
                  logger.info(`Mongoose: Setting debug to ${mongooseDebug}`);
              Severity: Minor
              Found in src/lib/mongoose.ts - 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 requiresExternalRoles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const requiresExternalRoles = (req) => {
                  const requiredRoles = config.get<string[]>('auth.requiredRoles');
              
                  // If there are required roles, check for them
                  if (req.user.bypassAccessCheck === false && requiredRoles.length > 0) {
              Severity: Minor
              Found in src/app/core/user/user-auth.middleware.ts - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Severity
              Category
              Status
              Source
              Language