Asymmetrik/node-rest-starter

View on GitHub

Showing 301 of 301 total issues

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

        it('should add textSearch function to query', () => {
            const query = TextExample.find();
            should.exist(query.textSearch);

            query.textSearch.should.be.Function();
Severity: Major
Found in src/app/common/mongoose/text-search.plugin.spec.ts and 2 other locations - About 1 hr to fix
src/app/common/mongoose/contains-search.plugin.spec.ts on lines 41..46
src/app/common/mongoose/paginate.plugin.spec.ts on lines 41..46

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

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

        it('should add containsSearch function to query', () => {
            const query = ContainsExample.find();
            should.exist(query.containsSearch);

            query.containsSearch.should.be.Function();
Severity: Major
Found in src/app/common/mongoose/contains-search.plugin.spec.ts and 2 other locations - About 1 hr to fix
src/app/common/mongoose/paginate.plugin.spec.ts on lines 41..46
src/app/common/mongoose/text-search.plugin.spec.ts on lines 25..30

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

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 rollbackMigrations has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const rollbackMigrations = async () => {
    logger.silent = process.argv?.[3] !== '--logger';
    logger.info('Started migration rollback...');

    const db = await mongoose.connect();
Severity: Minor
Found in src/rollback-migrations.ts - About 1 hr to fix

    Function search has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async search(
            queryParams = {},
            query: FilterQuery<TeamDocument> = {},
            search = '',
            user: UserDocument
    Severity: Minor
    Found in src/app/core/teams/teams.service.ts - About 1 hr to fix

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

      function proxyPkiUserSpec(key) {
          const spec = userSpec(key);
          spec.provider = 'proxy-pki';
          spec.providerData = {
              dn: key,
      Severity: Major
      Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 1 hr to fix
      src/app/core/user/auth/user-authentication.controller.spec.ts on lines 52..60

      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

          spec.cache.outdated.ts = DateTime.now()
              .minus({
                  milliseconds: 1000 * 60 * 60 * 24 * 10
              })
              .toJSDate();
      Severity: Major
      Found in src/app/core/access-checker/access-checker.service.spec.ts and 1 other location - About 1 hr to fix
      src/app/core/access-checker/access-checker.service.spec.ts on lines 77..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 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 createLogger has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function createLogger(loggerName: string) {
          const loggerConfig = config.get<IConfig>('logger').get<IConfig>(loggerName);
      
          const options = {
              format: combine(timestamp(), errors({ stack: true }), splat(), json()),
      Severity: Minor
      Found in src/lib/winston.ts - About 1 hr to fix

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

        export const getRecentMessages = async (req, res) => {
            const result = await messageService.getRecentMessages(req.user._id);
            res.status(StatusCodes.OK).json(result);
        };
        Severity: Major
        Found in src/app/core/messages/message.controller.ts and 1 other location - About 1 hr to fix
        src/app/core/teams/teams.controller.ts on lines 85..88

        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

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

        function proxyPkiUserSpec(key) {
            const spec = userSpec(key);
            spec.provider = 'proxy-pki';
            spec.providerData = {
                dn: key,
        src/app/core/teams/teams.service.spec.ts 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 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

        export const getAncestorTeamIds = async (req, res) => {
            const result = await teamsService.getAncestorTeamIds(req.body.teamIds);
            res.status(StatusCodes.OK).json(result);
        };
        Severity: Major
        Found in src/app/core/teams/teams.controller.ts and 1 other location - About 1 hr to fix
        src/app/core/messages/message.controller.ts on lines 98..101

        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

            spec.cache.expired.ts = DateTime.now()
                .minus({
                    milliseconds: 1000 * 60 * 60 * 24 * 10
                })
                .toJSDate();
        Severity: Major
        Found in src/app/core/access-checker/access-checker.service.spec.ts and 1 other location - About 1 hr to fix
        src/app/core/access-checker/access-checker.service.spec.ts on lines 86..90

        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

                    assert.calledWithMatch(emailService.sendMail, {
                        to: testUser.email,
                        from: config.get('coreEmails.default.from'),
                        replyTo: config.get('coreEmails.default.replyTo'),
                        subject: 'Your password has been changed',
        Severity: Major
        Found in src/app/core/user/auth/user-password.service.spec.ts and 1 other location - About 1 hr to fix
        src/app/core/user/auth/user-password.service.spec.ts on lines 150..156

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

        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

                    assert.calledWithMatch(emailService.sendMail, {
                        to: testUser.email,
                        from: config.get('coreEmails.default.from'),
                        replyTo: config.get('coreEmails.default.replyTo'),
                        subject: 'Password Reset',
        Severity: Major
        Found in src/app/core/user/auth/user-password.service.spec.ts and 1 other location - About 1 hr to fix
        src/app/core/user/auth/user-password.service.spec.ts on lines 183..189

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

        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

        export const updatePreferences = async (req, res) => {
            await userService.updatePreferences(req.user, req.body);
            res.status(StatusCodes.OK).json({});
        };
        Severity: Major
        Found in src/app/core/user/user.controller.ts and 1 other location - About 1 hr to fix
        src/app/core/user/user.controller.ts on lines 104..107

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

        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

                it('local auth and no bypass should be able to edit', () => {
                    const _user = new User({ bypassAccessCheck: false });
                    const result = userController.canEditProfile('local', _user);
                    result.should.equal(true);
                });
        Severity: Major
        Found in src/app/core/user/user.controller.spec.ts and 3 other locations - About 1 hr to fix
        src/app/core/user/user.controller.spec.ts on lines 284..288
        src/app/core/user/user.controller.spec.ts on lines 296..300
        src/app/core/user/user.controller.spec.ts on lines 302..306

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

        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

        export const updateRequiredOrgs = async (req, res) => {
            await userService.updateRequiredOrgs(req.user, req.body);
            res.status(StatusCodes.OK).json({});
        };
        Severity: Major
        Found in src/app/core/user/user.controller.ts and 1 other location - About 1 hr to fix
        src/app/core/user/user.controller.ts on lines 99..102

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

        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

                it('proxy-pki auth and no bypass should not be able to edit', () => {
                    const _user = new User({ bypassAccessCheck: false });
                    const result = userController.canEditProfile('proxy-pki', _user);
                    result.should.equal(false);
                });
        Severity: Major
        Found in src/app/core/user/user.controller.spec.ts and 3 other locations - About 1 hr to fix
        src/app/core/user/user.controller.spec.ts on lines 278..282
        src/app/core/user/user.controller.spec.ts on lines 284..288
        src/app/core/user/user.controller.spec.ts on lines 302..306

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

        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

                it('proxy-pki auth and bypass should be able to edit', () => {
                    const _user = new User({ bypassAccessCheck: true });
                    const result = userController.canEditProfile('proxy-pki', _user);
                    result.should.equal(true);
                });
        Severity: Major
        Found in src/app/core/user/user.controller.spec.ts and 3 other locations - About 1 hr to fix
        src/app/core/user/user.controller.spec.ts on lines 278..282
        src/app/core/user/user.controller.spec.ts on lines 284..288
        src/app/core/user/user.controller.spec.ts on lines 296..300

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

        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

                it('local auth and bypass should be able to edit', () => {
                    const _user = new User({ bypassAccessCheck: true });
                    const result = userController.canEditProfile('local', _user);
                    result.should.equal(true);
                });
        Severity: Major
        Found in src/app/core/user/user.controller.spec.ts and 3 other locations - About 1 hr to fix
        src/app/core/user/user.controller.spec.ts on lines 278..282
        src/app/core/user/user.controller.spec.ts on lines 296..300
        src/app/core/user/user.controller.spec.ts on lines 302..306

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

        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 buildExportStream has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const buildExportStream = (
            data: Readable | unknown,
            getRead: (unknown) => () => void,
            transforms: Transform[] = []
        ) => {
        Severity: Minor
        Found in src/app/core/export/export-config.controller.ts - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language