Asymmetrik/node-rest-starter

View on GitHub

Showing 301 of 301 total issues

Function verifyUser has 32 lines of code (exceeds 25 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 1 hr to fix

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

        authenticateAndLogin(req, res, next): Promise<IUser> {
            return new Promise((resolve, reject) => {
                // Attempt to authenticate the user using passport
                passport.authenticate(
                    config.get('auth.strategy'),
    Severity: Minor
    Found in src/app/core/user/auth/user-authentication.service.ts - About 1 hr to fix

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

          async init(server: http.Server, db: Mongoose) {
              // Load configured Socket Provider implementation
              await this.loadSocketProvider();
      
              // Initialize modules sockets
      Severity: Minor
      Found in src/lib/socket.io.ts - About 1 hr to fix

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

                it('should reject for user without specified role in team', async () => {
                    await teamsService
                        .meetsRoleRequirement(
                            user.explicit,
                            team.teamWithNoExternalTeam,
        Severity: Major
        Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 1 hr to fix
        src/app/core/teams/teams.service.spec.ts on lines 638..648

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

                    t = new Team({
                        ...spec.nestedTeam.nestedTeam2_1,
                        parent: team.nestedTeam2._id,
                        ancestors: [team.teamWithNoExternalTeam._id, team.nestedTeam2._id]
                    });
        Severity: Major
        Found in src/app/core/teams/teams.service.spec.ts and 2 other locations - About 1 hr to fix
        src/app/core/teams/teams.service.spec.ts on lines 1295..1299
        src/app/core/teams/teams.service.spec.ts on lines 1302..1306

        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

        export const deleteEntry = async (req, res) => {
            await cacheEntryService.delete(req.params.key);
            res.status(StatusCodes.NO_CONTENT).end();
        };
        Severity: Major
        Found in src/app/core/access-checker/access-checker.controller.ts and 1 other location - About 1 hr to fix
        src/app/core/access-checker/access-checker.controller.ts on lines 29..32

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

                    t = new Team({
                        ...spec.nestedTeam.nestedTeam1_1,
                        parent: team.nestedTeam1._id,
                        ancestors: [team.teamWithNoExternalTeam._id, team.nestedTeam1._id]
                    });
        Severity: Major
        Found in src/app/core/teams/teams.service.spec.ts and 2 other locations - About 1 hr to fix
        src/app/core/teams/teams.service.spec.ts on lines 1302..1306
        src/app/core/teams/teams.service.spec.ts on lines 1309..1313

        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

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

            cursorSearch(
                queryParams = {},
                search = '',
                query: FilterQuery<FeedbackDocument> = {},
                populate:
        Severity: Major
        Found in src/app/core/feedback/feedback.service.ts and 1 other location - About 1 hr to fix
        src/app/core/feedback/feedback.service.ts on lines 64..85

        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

        export const refreshEntry = async (req, res) => {
            await accessCheckerService.refreshEntry(req.params.key);
            res.status(StatusCodes.NO_CONTENT).end();
        };
        Severity: Major
        Found in src/app/core/access-checker/access-checker.controller.ts and 1 other location - About 1 hr to fix
        src/app/core/access-checker/access-checker.controller.ts on lines 34..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 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 getImplicitTeamIds has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async getImplicitTeamIds(
                user: IUser,
                ...roles: TeamRoles[]
            ): Promise<Types.ObjectId[]> {
                // Validate the user input
        Severity: Minor
        Found in src/app/core/teams/teams.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

            search(
                queryParams = {},
                search = '',
                query: FilterQuery<FeedbackDocument> = {},
                populate:
        Severity: Major
        Found in src/app/core/feedback/feedback.service.ts and 1 other location - About 1 hr to fix
        src/app/core/feedback/feedback.service.ts on lines 87..105

        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

                it('downgrade admin role; reject if team has no other admins', async () => {
                    await teamsService
                        .updateMemberRole(
                            user.user3,
                            team.teamWithNoExternalTeam,
        Severity: Major
        Found in src/app/core/teams/teams.service.spec.ts and 1 other location - About 1 hr to fix
        src/app/core/teams/teams.service.spec.ts on lines 293..305

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

                    t = new Team({
                        ...spec.nestedTeam.nestedTeam1_2,
                        parent: team.nestedTeam1._id,
                        ancestors: [team.teamWithNoExternalTeam._id, team.nestedTeam1._id]
                    });
        Severity: Major
        Found in src/app/core/teams/teams.service.spec.ts and 2 other locations - About 1 hr to fix
        src/app/core/teams/teams.service.spec.ts on lines 1295..1299
        src/app/core/teams/teams.service.spec.ts on lines 1309..1313

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

            sendMail(mailOptions: MailOptions): Promise<void> {
                return new Promise((resolve, reject) => {
                    const postData = this.transformMailOptions(mailOptions);
                    const options = this.getHttpsOptions();
                    options.path = this.config.paths.within;
        Severity: Minor
        Found in src/app/core/email/providers/https-email.provider.ts - About 1 hr to fix

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

                  if (config.get<string>('auth.strategy') === 'local') {
                      swaggerOptions.swaggerDefinition.components.securitySchemes = {
                          basicAuth: {
                              type: 'http',
                              scheme: 'basic'
          Severity: Major
          Found in src/lib/express.spec.ts and 1 other location - About 1 hr to fix
          src/lib/express.ts on lines 237..244

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

          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

              if (config.get<string>('auth.strategy') === 'local') {
                  swaggerOptions.swaggerDefinition.components.securitySchemes = {
                      basicAuth: {
                          type: 'http',
                          scheme: 'basic'
          Severity: Major
          Found in src/lib/express.ts and 1 other location - About 1 hr to fix
          src/lib/express.spec.ts on lines 44..51

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

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

              async generateMailOptions(
                  user,
                  req,
                  emailTemplateConfig,
                  emailContentData = {},
          Severity: Minor
          Found in src/app/core/email/email.service.ts - About 1 hr to fix

            Function requestNewTeam has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async requestNewTeam(
                    org: string,
                    aoi: string,
                    description: string,
                    requester: UserDocument,
            Severity: Minor
            Found in src/app/core/teams/teams.service.ts - About 1 hr to fix

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

                  async welcomeWithAccessEmail(user: UserDocument, req) {
                      if (!config.get('coreEmails.welcomeWithAccess.enabled')) {
                          return;
                      }
              
              
              Severity: Minor
              Found in src/app/core/user/user-email.service.ts - About 1 hr to fix

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

                    streamToCsv(columns: ExportColumnDef[]): Transform {
                        // Create a stream to turn Mongo records into CSV rows
                        const stream = through2.obj((chunk, enc, callback) => {
                            const row = [];
                
                
                Severity: Minor
                Found in src/app/common/csv-stream.service.ts - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language