teableio/teable

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

Summary

Maintainability
C
1 day
Test Coverage

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

import { Injectable, Logger } from '@nestjs/common';
import type { IGridColumnMeta, IFilter, IGroup } from '@teable/core';
import { mergeWithDefaultFilter, nullsToUndefined, StatisticsFunc, ViewType } from '@teable/core';
import type { Prisma } from '@teable/db-main-prisma';
import { PrismaService } from '@teable/db-main-prisma';
Severity: Minor
Found in apps/nestjs-backend/src/features/aggregation/aggregation.service.ts - About 6 hrs to fix

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

      async performGroupedAggregation(params: {
        aggregations: IRawAggregations;
        statisticFields: IAggregationField[] | undefined;
        filter?: IFilter;
        search?: [string, string] | [string];
    Severity: Minor
    Found in apps/nestjs-backend/src/features/aggregation/aggregation.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 performAggregation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      async performAggregation(params: {
        tableId: string;
        withFieldIds?: string[];
        withView?: IWithView;
        search?: [string, string] | [string];
    Severity: Minor
    Found in apps/nestjs-backend/src/features/aggregation/aggregation.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 handleRowCount has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      private async handleRowCount(params: {
        tableId: string;
        dbTableName: string;
        fieldInstanceMap: Record<string, IFieldInstance>;
        fieldInstanceMapWithoutHiddenFields: Record<string, IFieldInstance>;
    Severity: Minor
    Found in apps/nestjs-backend/src/features/aggregation/aggregation.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 handleAggregation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private async handleAggregation(params: {
        dbTableName: string;
        fieldInstanceMap: Record<string, IFieldInstance>;
        fieldInstanceMapWithoutHiddenFields: Record<string, IFieldInstance>;
        filter?: IFilter;
    Severity: Minor
    Found in apps/nestjs-backend/src/features/aggregation/aggregation.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