teableio/teable

View on GitHub
apps/nestjs-backend/src/features/record/record.service.ts

Summary

Maintainability
F
6 days
Test Coverage

File record.service.ts has 1459 lines of code (exceeds 300 allowed). Consider refactoring.
Open

/* eslint-disable @typescript-eslint/naming-convention */
import {
  BadRequestException,
  Injectable,
  InternalServerErrorException,
Severity: Major
Found in apps/nestjs-backend/src/features/record/record.service.ts - About 3 days to fix

    RecordService has 50 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Injectable()
    export class RecordService {
      private logger = new Logger(RecordService.name);
    
      constructor(
    Severity: Minor
    Found in apps/nestjs-backend/src/features/record/record.service.ts - About 7 hrs to fix

      Function getViewProjection has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        private async getViewProjection(
          tableId: string,
          query: IGetRecordsRo
        ): Promise<Record<string, boolean> | undefined> {
          const viewId = query.viewId;
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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 groupDbCollection2GroupPoints has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        @Timing()
        // eslint-disable-next-line sonarjs/cognitive-complexity
        private async groupDbCollection2GroupPoints(
          groupResult: { [key: string]: unknown; __c: number }[],
          groupFields: IFieldInstance[],
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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 buildLinkCandidateQuery has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        async buildLinkCandidateQuery(
          queryBuilder: Knex.QueryBuilder,
          tableId: string,
          dbTableName: string,
          filterLinkCellCandidate: [string, string] | string
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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 getPreviewUrlTokenMap has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        private async getPreviewUrlTokenMap(
          records: ISnapshotBase<IRecord>[],
          fields: IFieldInstance[],
          fieldKeyType: FieldKeyType
        ) {
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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 recordsPresignedUrl has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        @Timing()
        private async recordsPresignedUrl(
          records: ISnapshotBase<IRecord>[],
          fields: IFieldInstance[],
          fieldKeyType: FieldKeyType
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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 buildFilterSortQuery has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        async buildFilterSortQuery(
          tableId: string,
          query: Pick<
            IGetRecordsRo,
            | 'viewId'
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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 updateRecordIndexes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        async updateRecordIndexes(
          tableId: string,
          recordsWithOrder: {
            id: string;
            order?: Record<string, number>;
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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 buildLinkSelectedQuery has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        async buildLinkSelectedQuery(
          queryBuilder: Knex.QueryBuilder,
          tableId: string,
          dbTableName: string,
          filterLinkCellSelected: [string, string] | string
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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 getRecordIndexes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        async getRecordIndexes(
          tableId: string,
          recordIds: string[],
          viewId?: string
        ): Promise<Record<string, number>[] | undefined> {
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.service.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 createBatch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        private async createBatch(
          tableId: string,
          records: IRecordInnerRo[],
          fieldKeyType: FieldKeyType,
          fieldRaws: IFieldRaws
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.service.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 getFilterByCollapsedGroup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        private getFilterByCollapsedGroup({
          groupBy,
          groupPoints,
          fieldInstanceMap,
          collapsedGroupIds,
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.service.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 getGroupRelatedData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        public async getGroupRelatedData(tableId: string, query?: IGetRecordsRo) {
          const { viewId, groupBy: extraGroupBy, filter, search, collapsedGroupIds } = query || {};
          let groupPoints: IGroupPoint[] = [];
      
          const groupBy = parseGroup(extraGroupBy);
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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

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

        private async getFieldsByProjection(
          tableId: string,
          projection?: { [fieldNameOrId: string]: boolean },
          fieldKeyType: FieldKeyType = FieldKeyType.Id
        ) {
      Severity: Minor
      Found in apps/nestjs-backend/src/features/record/record.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

      There are no issues that match your filters.

      Category
      Status