Asymmetrik/node-rest-starter

View on GitHub

Showing 66 of 301 total issues

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

    login(user: UserDocument, req): Promise<IUser> {
        return new Promise((resolve, reject) => {
            // Calls the login function (which goes to passport)
            req.login(user, (err) => {
                if (err) {
Severity: Minor
Found in src/app/core/user/auth/user-authentication.service.ts - About 1 hr to fix

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

    UserSchema.methods.auditCopy = function (userIP?: string) {
        const toReturn: Record<string, unknown> = {};
    
        const asObject = this.toObject();
    
    
    Severity: Minor
    Found in src/app/core/user/user.model.ts - About 1 hr to fix

      Function containsSearchPlugin has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function containsSearchPlugin<
          EnforcedDocType,
          TModelType,
          TInstanceMethods
      >(
      Severity: Minor
      Found in src/app/common/mongoose/contains-search.plugin.ts - About 1 hr to fix

        Function requiresRoleHelper has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                const requiresRoleHelper = (method, testFunction) => {
                    describe(method, () => {
                        it('user not found', async () => {
                            sandbox.stub(teamsService, 'meetsRoleRequirement').resolves();
        
        
        Severity: Minor
        Found in src/app/core/teams/teams.controller.spec.ts - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                          if (implicitFilter) {
                              query.$or.push(implicitFilter);
                          }
          Severity: Major
          Found in src/app/core/teams/teams.service.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (isExternal) {
                                        _.remove(query.$or, (filter) => filter[`roles.${role}`]);
                                    }
            Severity: Major
            Found in src/app/core/user/auth/user-authorization.service.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              if (implicitFilter) {
                                  query.$or.push(implicitFilter);
                              }
              Severity: Major
              Found in src/app/core/teams/teams.service.ts - About 45 mins to fix

                Function welcomeWithAccessEmail has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 defaultErrorHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                export const defaultErrorHandler: ErrorRequestHandler = (
                    err,
                    req,
                    res,
                    next
                Severity: Minor
                Found in src/app/common/express/error-handlers.ts - About 35 mins 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 getHttpsOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    getHttpsOptions() {
                        if (!this.options) {
                            this.options = {
                                host: this.config.hostname,
                                port: this.config.port,
                Severity: Minor
                Found in src/app/core/email/providers/https-email.provider.ts - About 35 mins 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 payloadHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    payloadHandler(topic: string, message: MessageType) {
                        // Gracefully handle empty messages by ignoring and logging
                        if (null == message) {
                            logger.warn(
                                `${this.constructor.name}: Ignoring empty message ${message}`
                Severity: Minor
                Found in src/app/common/sockets/base-socket.provider.ts - About 35 mins 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 search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                export const search = async function (req, res) {
                    const search = req.body.s || null;
                    let query = req.body.q || {};
                    query = util.toMongoose(query);
                
                
                Severity: Minor
                Found in src/app/core/audit/audit.controller.ts - About 35 mins 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 rollbackMigrations has a Cognitive Complexity of 7 (exceeds 5 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 35 mins 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

                Avoid too many return statements within this function.
                Open

                        return null;
                Severity: Major
                Found in src/app/common/util.service.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return Promise.reject(
                                  new Error(
                                      `Error retrieving entry from the access checker provider: ${ex.message}`
                                  )
                              );
                  Severity: Major
                  Found in src/app/core/access-checker/access-checker.service.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return done(null, primaryUser);
                    Severity: Major
                    Found in src/lib/strategies/proxy-pki.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return done(null, false, err);
                      Severity: Major
                      Found in src/lib/strategies/proxy-pki.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return done(
                                        null,
                                        false,
                                        new UnauthorizedError(
                                            'Could not authenticate request, please verify your credentials.'
                        Severity: Major
                        Found in src/lib/strategies/proxy-pki.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return parsed;
                          Severity: Major
                          Found in src/app/common/util.service.ts - About 30 mins to fix

                            Function dateParse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export const dateParse = function (
                                // eslint-disable-next-line @typescript-eslint/ban-types
                                date: string | number | Date | Array<unknown> | Function | Object
                            ) {
                                // Handle nil values, arrays, and functions by simply returning null
                            Severity: Minor
                            Found in src/app/common/util.service.ts - About 25 mins 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

                            Severity
                            Category
                            Status
                            Source
                            Language