mashafrancis/butternut-user

View on GitHub

Showing 33 of 33 total issues

Function createGqlOptions has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    createGqlOptions(): GqlModuleOptions {
        return {
            typePaths: [join(process.cwd(), '**/*.graphql')],
            introspection: true,
            playground: true,
Severity: Major
Found in src/app/_helpers/graphql/gql-config.service.ts - About 2 hrs to fix

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

            this.client.send({ cmd: USER_CMD_PASSWORD_NEW }, user).subscribe(
                () =>
                    this.logger.debug(
                        `[passwordNew] Sent command for new password for email ${user.email}`,
                    ),
    Severity: Major
    Found in src/app/auth/auth.controller.ts and 2 other locations - About 2 hrs to fix
    src/app/auth/auth.controller.ts on lines 95..101
    src/app/auth/auth.controller.ts on lines 124..130

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    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

                this.client.send({ cmd: USER_CMD_REGISTER }, user).subscribe(
                    () =>
                        this.logger.debug(
                            `[registerVerify] Sent command registry verify for email ${body.email}`,
                        ),
    Severity: Major
    Found in src/app/auth/auth.controller.ts and 2 other locations - About 2 hrs to fix
    src/app/auth/auth.controller.ts on lines 95..101
    src/app/auth/auth.controller.ts on lines 180..186

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

    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

        public async findAll(options?: FindManyOptions<T>): Promise<T[]> {
            if (options.where) {
                options.where = typeormFilterMapper(options);
            }
            const entities = await this.repository.find(options);
    Severity: Major
    Found in src/base/crud.service.ts and 1 other location - About 2 hrs to fix
    src/base/crud.service.ts on lines 58..68

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

    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

            this.client.send({ cmd: USER_CMD_REGISTER_VERIFY }, user).subscribe(
                () =>
                    this.logger.debug(
                        `[registerVerify] Sent command register verify for user id ${user.id}`,
                    ),
    Severity: Major
    Found in src/app/auth/auth.controller.ts and 2 other locations - About 2 hrs to fix
    src/app/auth/auth.controller.ts on lines 124..130
    src/app/auth/auth.controller.ts on lines 180..186

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

    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

        public async findOne(options?: FindOneOptions<T>): Promise<T> {
            if (options.where) {
                options.where = typeormFilterMapper(options);
            }
            const entity = await this.repository.findOne(options);
    Severity: Major
    Found in src/base/crud.service.ts and 1 other location - About 2 hrs to fix
    src/base/crud.service.ts on lines 27..37

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

    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

        @Put('/:id')
        public async update(@Body() data: DeepPartial<T>): Promise<T> {
            return this.service.update(data);
        }
    Severity: Major
    Found in src/base/rest.controller.ts and 1 other location - About 1 hr to fix
    src/base/rest.controller.ts on lines 30..33

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 63.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        @Post('/')
        public async create(@Body() data: DeepPartial<T>): Promise<T> {
            return this.service.create(data);
        }
    Severity: Major
    Found in src/base/rest.controller.ts and 1 other location - About 1 hr to fix
    src/base/rest.controller.ts on lines 35..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 63.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function constructor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        constructor(label?: string) {
            const options = {
                file: {
                    level: 'info' || 'error',
                    filename: `${__dirname}/../../logs/app.log`,
    Severity: Minor
    Found in src/app/app.logger.ts - About 1 hr to fix

      Function onUserRegister has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @MessagePattern({ cmd: USER_CMD_REGISTER })
          public async onUserRegister(user: UserEntity): Promise<void> {
              try {
                  const userRecord = await this.userService.findByEmail(user.email);
                  this.logger.debug(
      Severity: Minor
      Found in src/app/user/user.controller.ts - About 1 hr to fix

        Function generate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            generate: (function () {
                // Timestamp of last push, used to prevent local
                // collisions if you push twice in one ms.
                let lastPushTime = 0;
                // We generate 72-bits of randomness which get
        Severity: Minor
        Found in src/utils/fancyGenerator.ts - About 1 hr to fix

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

                      await mail({
                          subject: `Reset your password`,
                          to: user.email,
                          html: renderTemplate(`/mail/password_reset.twig`, {
                              user,
          Severity: Major
          Found in src/app/user/user.controller.ts and 1 other location - About 1 hr to fix
          src/app/user/user.controller.ts on lines 84..92

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 60.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      await mail({
                          subject: `Verify your account`,
                          to: userRecord.email,
                          html: renderTemplate(`/mail/verify_registration.twig`, {
                              user,
          Severity: Major
          Found in src/app/user/user.controller.ts and 1 other location - About 1 hr to fix
          src/app/user/user.controller.ts on lines 140..148

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 60.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              @Command({ command: 'create:user [amount]', describe: 'create a user' })
              public async create(@Positional({ name: 'amount' }) amount) {
                  // tslint:disable-next-line:no-parameter-reassignment
                  amount = parseInt(amount || 10, 10);
                  this.logger.debug(`[create] execute for amount ${amount}!`);
          Severity: Minor
          Found in src/app/user/user.command.ts - About 1 hr to fix

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

            const mapToTypeOrm = (key, filter): any => {
                switch (key) {
                    case 'eq':
                        return { $eq: filter[key] };
                    case 'ne':
            Severity: Minor
            Found in src/app/_helpers/database/typeorm-filter.mapper.ts - About 1 hr to fix

              Function onUserPasswordReset has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @MessagePattern({ cmd: USER_CMD_PASSWORD_RESET })
                  public async onUserPasswordReset({
                      email,
                  }: {
                      email: string;
              Severity: Minor
              Found in src/app/user/user.controller.ts - About 1 hr to fix

                Function login has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public async login(credentials: CredentialsDto): Promise<UserEntity> {
                        const user = await this.findByEmail(credentials.email);
                        const validPassword = await verifyPassword(
                            user.password,
                            credentials.password,
                Severity: Minor
                Found in src/app/user/user.service.ts - About 1 hr to fix

                  Function createGqlOptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      createGqlOptions(): GqlModuleOptions {
                          return {
                              typePaths: [join(process.cwd(), '**/*.graphql')],
                              introspection: true,
                              playground: true,
                  Severity: Minor
                  Found in src/app/_helpers/graphql/gql-config.service.ts - 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

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

                  export class UpdateUserInput {
                      first_name?: string;
                      last_name?: string;
                      email?: string;
                      phone_num?: string;
                  Severity: Major
                  Found in src/app/graphql.schema.ts and 1 other location - About 1 hr to fix
                  src/app/user/dto/update-user.dto.ts on lines 2..10

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

                  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

                  export class UpdateUserInput {
                      first_name?: string;
                      last_name?: string;
                      email?: string;
                      phone_num?: string;
                  Severity: Major
                  Found in src/app/user/dto/update-user.dto.ts and 1 other location - About 1 hr to fix
                  src/app/graphql.schema.ts on lines 12..20

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language