Asymmetrik/node-rest-starter

View on GitHub

Showing 66 of 301 total issues

Function audit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async audit(
        message: string,
        eventType: string,
        eventAction: string,
        requestOrEventActor: Request | Promise<Partial<IUser>> | Partial<IUser>,
Severity: Minor
Found in src/app/core/audit/audit.service.ts - About 1 hr to fix

    Function paginatePlugin has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function paginatePlugin<EnforcedDocType, TModelType, TInstanceMethods>(
        schema: Schema<EnforcedDocType, TModelType, TInstanceMethods>
    ) {
        schema.query['paginate'] = async function <DocType>(
            this: Query<HydratedDocument<DocType>[], DocType>,
    Severity: Minor
    Found in src/app/common/mongoose/paginate.plugin.ts - About 1 hr to fix

      Function updateCurrentUser has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const updateCurrentUser = async (req, res) => {
          // Make sure the user is logged in
          if (null == req.user) {
              throw new BadRequestError('User is not logged in');
          }
      Severity: Minor
      Found in src/app/core/user/user.controller.ts - About 1 hr to fix

        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

            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

              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

                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

                      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

                      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

                        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

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

                                    updateRoles(user) {
                                        if (this.provider) {
                                            const strategy = this.getRoleStrategy();
                                            const isHybrid = strategy === 'hybrid';
                                
                                
                                Severity: Minor
                                Found in src/app/core/user/auth/user-authorization.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

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

                                export const verify = (role) => {
                                    return function (req, res, next) {
                                        // Grab the Authentication header
                                        const authentication = req.headers.authentication;
                                        if (null == authentication) {
                                Severity: Minor
                                Found in src/app/core/token-auth.server.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

                                Function initMiddleware has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function initMiddleware(app: Express) {
                                    // Showing stack errors
                                    app.set('showStackError', true);
                                
                                    // Should be placed before express.static
                                Severity: Minor
                                Found in src/lib/express.ts - About 1 hr to fix

                                  Function updateTeams has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      async updateTeams(user: IUser) {
                                          const strategy = config.get('teams.implicitMembers.strategy');
                                          const nestedTeamsEnabled = config.get<boolean>('teams.nestedTeams');
                                  
                                          if (strategy === 'disabled' && !nestedTeamsEnabled) {
                                  Severity: Minor
                                  Found in src/app/core/teams/teams.service.ts - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language