teableio/teable

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

Summary

Maintainability
F
4 days
Test Coverage

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

import {
  BadRequestException,
  Injectable,
  InternalServerErrorException,
  Logger,
Severity: Major
Found in apps/nestjs-backend/src/features/calculation/reference.service.ts - About 2 days to fix

    ReferenceService has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

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

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

        private calculateComputeField(
          field: IFieldInstance,
          fieldMap: IFieldMap,
          recordItem: IRecordItem,
          userMap?: { [userId: string]: IUserInfoVo }
      Severity: Minor
      Found in apps/nestjs-backend/src/features/calculation/reference.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 calculateLookup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        private calculateLookup(
          field: IFieldInstance,
          lookedField: IFieldInstance,
          recordItem: IRecordItem
        ) {
      Severity: Minor
      Found in apps/nestjs-backend/src/features/calculation/reference.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 getLinkOrderFromTopoOrders has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        getLinkOrderFromTopoOrders(params: {
          topoOrders: ITopoItem[];
          fieldMap: IFieldMap;
        }): ITopoLinkOrder[] {
          const newOrder: ITopoLinkOrder[] = [];
      Severity: Minor
      Found in apps/nestjs-backend/src/features/calculation/reference.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 calculateLink has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        private calculateLink(
          field: LinkFieldDto,
          virtualField: IFieldInstance,
          record: IRecord,
          lookupValues: unknown
      Severity: Minor
      Found in apps/nestjs-backend/src/features/calculation/reference.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 calculateRollupAndLink has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        private calculateRollupAndLink(
          field: IFieldInstance,
          relationship: Relationship,
          lookupField: IFieldInstance,
          record: IRecord,
      Severity: Minor
      Found in apps/nestjs-backend/src/features/calculation/reference.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 affectedRecordItemsQuerySql has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        affectedRecordItemsQuerySql(
          startFieldIds: string[],
          fieldMap: IFieldMap,
          linkAdjacencyMap: IAdjacencyMap,
          startRecordIds: string[]
      Severity: Minor
      Found in apps/nestjs-backend/src/features/calculation/reference.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

      Avoid too many return statements within this function.
      Open

              return dependencies[0].fields[fieldId] ?? null;
      Severity: Major
      Found in apps/nestjs-backend/src/features/calculation/reference.service.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return null;
        Severity: Major
        Found in apps/nestjs-backend/src/features/calculation/reference.service.ts - About 30 mins to fix

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

            private shouldSkipCompute(field: IFieldInstance, recordItem: IRecordItem) {
              if (!field.isComputed && field.type !== FieldType.Link) {
                return true;
              }
          
          
          Severity: Minor
          Found in apps/nestjs-backend/src/features/calculation/reference.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 joinOriginLookup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private joinOriginLookup(lookupField: IFieldInstance, lookupValues: unknown[] | unknown) {
              if (Array.isArray(lookupValues)) {
                const flatten = lookupValues.map((value) => {
                  if (Array.isArray(value)) {
                    return lookupField.cellValue2String(value);
          Severity: Minor
          Found in apps/nestjs-backend/src/features/calculation/reference.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 getComputedUsers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private getComputedUsers(
              field: IFieldInstance,
              record: IRecord,
              userMap: { [userId: string]: IUserInfoVo }
            ) {
          Severity: Minor
          Found in apps/nestjs-backend/src/features/calculation/reference.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