kepelrs/nestjs-prisma-crud

View on GitHub

Showing 9 of 9 total issues

Function plainToPrismaNestedQuery has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function plainToPrismaNestedQuery(
    objectToPersist: any,
    currentPersistedObject: any,
    allowedJoinSet: Set<string>,
    idPropertyName: string,
Severity: Major
Found in src/crud/helpers.ts - About 2 hrs to fix

    Function deleteObjectProperties has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function deleteObjectProperties(
        object: any,
        blacklistedPropertyPaths?: Array<string | RegExp>,
        whitelistedPropertyPaths?: Array<string | RegExp>,
        ignoreArrayIndexes = false,
    Severity: Minor
    Found in src/crud/helpers.ts - About 1 hr to fix

      Function findMany has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public async findMany(opts: CrudMethodOpts) {
              const fullOpts = this.getFullCrudOpts(opts);
              const repo = this.getRepo(fullOpts);
      
              const parsedCrudQuery = this.prismaQueryBuilder.parseCrudQuery(fullOpts.crudQuery);
      Severity: Minor
      Found in src/crud/prisma-crud.service.ts - About 1 hr to fix

        Function RBAC has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        export const RBAC = <T extends AllowedRolesId = AllowedRolesId>(
            allowedRoles: AllowedRoles<T>,
            authData: any,
            moduleRef: ModuleRef,
        ): PolicyMethod => (_: ExecutionContext) => {
        Severity: Minor
        Found in src/access-control/builtin-policies/rbac.policy.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 RBAC has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ): PolicyMethod => (_: ExecutionContext) => {
            if (allowedRoles === 'everyone') {
                return;
            }
        
        
        Severity: Minor
        Found in src/access-control/builtin-policies/rbac.policy.ts - About 1 hr to fix

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

          export function validateNestedWhere(
              whereObject: any,
              allowedJoinsSet: Set<string>,
          
              // TODO: Document that below keywords should be forbidden in all models
          Severity: Minor
          Found in src/crud/validations.ts - About 1 hr to fix

            Function transformJoinsToInclude has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export function transformJoinsToInclude(joins: string[]) {
                if (!joins.length) {
                    return {};
                }
            
            
            Severity: Minor
            Found in src/crud/helpers.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 MustMatchAuthAttribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            export const MustMatchAuthAttribute = (
                modelAttributePath: string,
                authDataAttributePath: string,
            ): PolicyMethod => (ctx: ExecutionContext, authData: any, _moduleRef: ModuleRef) => {
                const request = ctx.switchToHttp().getRequest();
            Severity: Minor
            Found in src/access-control/builtin-policies/must-match-auth-attribute.policy.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 findMany has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public async findMany(opts: CrudMethodOpts) {
                    const fullOpts = this.getFullCrudOpts(opts);
                    const repo = this.getRepo(fullOpts);
            
                    const parsedCrudQuery = this.prismaQueryBuilder.parseCrudQuery(fullOpts.crudQuery);
            Severity: Minor
            Found in src/crud/prisma-crud.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