Vizzuality/nestjs-base-service

View on GitHub

Showing 5 of 14 total issues

BaseService has 31 functions (exceeds 20 allowed). Consider refactoring.
Open

export abstract class BaseService<Entity extends object, CreateModel, UpdateModel, Info> {
  protected logger: Logger | NoOpLogger;
  private readonly options: BaseServiceOptions;

  constructor(
Severity: Minor
Found in src/base.service.ts - About 3 hrs to fix

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

    import { Logger, NotFoundException, ForbiddenException, LoggerService } from '@nestjs/common';
    
    import { Repository, SelectQueryBuilder } from 'typeorm';
    
    import { IPaginationOptions, paginate, Pagination } from 'nestjs-typeorm-paginate';
    Severity: Minor
    Found in src/base.service.ts - About 2 hrs to fix

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

        (
          processFetchSpecificationArgs: ProcessFetchSpecificationArguments = {},
          ctx: ExecutionContext
        ) => {
          const request = ctx.switchToHttp().getRequest();
      Severity: Minor
      Found in src/decorators/process-fetch-specification.decorator.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 ProcessFetchSpecification has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        (
          processFetchSpecificationArgs: ProcessFetchSpecificationArguments = {},
          ctx: ExecutionContext
        ) => {
          const request = ctx.switchToHttp().getRequest();
      Severity: Major
      Found in src/decorators/process-fetch-specification.decorator.ts - About 2 hrs to fix

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

          static addIncludedEntities<T>(
            query: SelectQueryBuilder<T>,
            aliasTable: string,
            { include = undefined }: Pick<FetchSpecification, 'include'> = {
              include: undefined,
        Severity: Minor
        Found in src/utils/fetch.utils.ts - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language