teableio/teable

View on GitHub
apps/nestjs-backend/src/event-emitter/event-emitter.service.ts

Summary

Maintainability
B
6 hrs
Test Coverage

File event-emitter.service.ts has 338 lines of code (exceeds 300 allowed). Consider refactoring.
Open

import { Injectable, Logger } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import type { ICreateOpBuilder, IOpBuilder, IOpContextBase, IOtOperation } from '@teable/core';
import {
  FieldOpBuilder,
Severity: Minor
Found in apps/nestjs-backend/src/event-emitter/event-emitter.service.ts - About 2 hrs to fix

    EventEmitterService has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Injectable()
    export class EventEmitterService {
      private readonly logger = new Logger(EventEmitterService.name);
    
      private readonly eventNameMapping = {
    Severity: Minor
    Found in apps/nestjs-backend/src/event-emitter/event-emitter.service.ts - About 2 hrs to fix

      Function generateEventsFromRawOps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        private generateEventsFromRawOps(rawOpMap: IRawOpMap, eventManager: Map<string, OpEvent>) {
          for (const collection in rawOpMap) {
            const [docType, docId] = collection.split('_') as [DocType, string];
            const data = rawOpMap[collection];
      
      
      Severity: Minor
      Found in apps/nestjs-backend/src/event-emitter/event-emitter.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 buildAndApplyOp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        private buildAndApplyOp(
          otOperation: IOtOperation,
          acc: object,
          propertyCategory: string,
          nodeId: string,
      Severity: Minor
      Found in apps/nestjs-backend/src/event-emitter/event-emitter.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