Asymmetrik/node-rest-starter

View on GitHub

Showing 66 of 301 total issues

File teams.service.spec.ts has 1442 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from 'lodash';
import mongoose from 'mongoose';
import should from 'should';
import { assert, createSandbox } from 'sinon';

Severity: Major
Found in src/app/core/teams/teams.service.spec.ts - About 3 days to fix

    File teams.service.ts has 648 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import _ from 'lodash';
    import mongoose, { FilterQuery, PopulateOptions, Types } from 'mongoose';
    
    import {
        TeamRoleImplicit,
    Severity: Major
    Found in src/app/core/teams/teams.service.ts - About 1 day to fix

      File user-authentication.controller.spec.ts has 554 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import _ from 'lodash';
      import { DateTime } from 'luxon';
      import passport from 'passport';
      import should from 'should';
      import { assert, createSandbox } from 'sinon';
      Severity: Major
      Found in src/app/core/user/auth/user-authentication.controller.spec.ts - About 1 day to fix

        File util.service.spec.ts has 534 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import should from 'should';
        
        import { utilService } from '../../dependencies';
        
        /**
        Severity: Major
        Found in src/app/common/util.service.spec.ts - About 1 day to fix

          Function updateMemberFilter has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

              updateMemberFilter(query: FilterQuery<UserDocument>, team: TeamDocument) {
                  // Extract member types and roles for filtering
                  const types = query.$and?.find((filter) => filter.type)?.type.$in ?? [];
                  const roles: TeamRoles[] =
                      query.$and?.find((filter) => filter.role)?.role.$in ?? [];
          Severity: Minor
          Found in src/app/core/teams/teams.service.ts - About 4 hrs 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

          File user.model.ts has 334 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import crypto, { BinaryLike } from 'crypto';
          
          import _ from 'lodash';
          import mongoose, {
              HydratedDocument,
          Severity: Minor
          Found in src/app/core/user/user.model.ts - About 4 hrs to fix

            TeamsService has 32 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class TeamsService {
                constructor(
                    private model: TeamModel,
                    private userModel: UserModel
                ) {}
            Severity: Minor
            Found in src/app/core/teams/teams.service.ts - About 4 hrs to fix

              File teams.controller.spec.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { Request } from 'express';
              import should from 'should';
              import { assert, createSandbox, match, stub } from 'sinon';
              
              import { Team, TeamDocument } from './team.model';
              Severity: Minor
              Found in src/app/core/teams/teams.controller.spec.ts - About 3 hrs to fix

                File default.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                'use strict';
                
                const contactEmail = process.env.CONTACT_EMAIL || 'noreply@bluehalo.com';
                
                module.exports = {
                Severity: Minor
                Found in config/default.js - About 2 hrs to fix

                  File user-authorization.service.spec.ts has 282 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import mongoose from 'mongoose';
                  import should from 'should';
                  import { createSandbox } from 'sinon';
                  
                  import userAuthorizationService from './user-authorization.service';
                  Severity: Minor
                  Found in src/app/core/user/auth/user-authorization.service.spec.ts - About 2 hrs to fix

                    Function getImplicitTeamIds has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async getImplicitTeamIds(
                            user: IUser,
                            ...roles: TeamRoles[]
                        ): Promise<Types.ObjectId[]> {
                            // Validate the user input
                    Severity: Major
                    Found in src/app/core/teams/teams.service.ts - About 2 hrs to fix

                      Function verify has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async verify(req, [primaryUserDn, proxiedUserDn, masqueradeUserDn], done) {
                              // If there is no DN, we can't authenticate
                              if (!primaryUserDn) {
                                  return done(null, false, new BadRequestError('Missing certificate'));
                              }
                      Severity: Major
                      Found in src/lib/strategies/proxy-pki.ts - About 2 hrs to fix

                        File user.model.spec.ts has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import * as assert from 'assert';
                        
                        import { Types } from 'mongoose';
                        import should from 'should';
                        
                        
                        Severity: Minor
                        Found in src/app/core/user/user.model.spec.ts - About 2 hrs to fix

                          File user.controller.spec.ts has 267 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import { assert, createSandbox } from 'sinon';
                          
                          import userAuthorizationService from './auth/user-authorization.service';
                          import * as userController from './user.controller';
                          import { User } from './user.model';
                          Severity: Minor
                          Found in src/app/core/user/user.controller.spec.ts - About 2 hrs to fix

                            Function initSwaggerAPI has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function initSwaggerAPI(app: Express) {
                                // apiDocs must be enabled explicitly in the config
                                if (config.get<boolean>('apiDocs.enabled') !== true) {
                                    return;
                                }
                            Severity: Major
                            Found in src/lib/express.ts - About 2 hrs to fix

                              Function updateMemberFilter has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  updateMemberFilter(query: FilterQuery<UserDocument>, team: TeamDocument) {
                                      // Extract member types and roles for filtering
                                      const types = query.$and?.find((filter) => filter.type)?.type.$in ?? [];
                                      const roles: TeamRoles[] =
                                          query.$and?.find((filter) => filter.role)?.role.$in ?? [];
                              Severity: Major
                              Found in src/app/core/teams/teams.service.ts - About 2 hrs to fix

                                Function updateUserFilter has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    updateUserFilter(query: FilterQuery<UserDocument>) {
                                        if (this.provider) {
                                            // Update role filters based on roleStrategy
                                            const strategy = this.getRoleStrategy();
                                            const isExternal = strategy === 'external';
                                Severity: Minor
                                Found in src/app/core/user/auth/user-authorization.service.ts - About 2 hrs 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 verify has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    async verify(req, [primaryUserDn, proxiedUserDn, masqueradeUserDn], done) {
                                        // If there is no DN, we can't authenticate
                                        if (!primaryUserDn) {
                                            return done(null, false, new BadRequestError('Missing certificate'));
                                        }
                                Severity: Minor
                                Found in src/lib/strategies/proxy-pki.ts - About 2 hrs 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 47 lines of code (exceeds 25 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 1 hr to fix

                                  Function adminGetCSV has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export const adminGetCSV = (req, res) => {
                                      const exportConfig = req.exportConfig as IExportConfig;
                                      const exportQuery = req.exportQuery as FilterQuery<UserDocument>;
                                  
                                      const fileName = `${config.get('app.instanceName')}-${exportConfig.type}.csv`;
                                  Severity: Minor
                                  Found in src/app/core/user/admin/user-admin.controller.ts - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language