teableio/teable

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

Summary

Maintainability
B
4 hrs
Test Coverage

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

/* eslint-disable sonarjs/no-duplicate-string */
import { Injectable, NotFoundException } from '@nestjs/common';
import {
  generatePluginId,
  generatePluginUserId,
Severity: Minor
Found in apps/nestjs-backend/src/features/plugin/plugin.service.ts - About 3 hrs to fix

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

      async updatePlugin(id: string, updatePluginRo: IUpdatePluginRo): Promise<IUpdatePluginVo> {
        const userId = this.cls.get('user.id');
        const isAdmin = this.cls.get('user.isAdmin');
        const { name, description, detailDesc, helpUrl, logo, i18n, positions, url } = updatePluginRo;
        const res = await this.prismaService.$tx(async (prisma) => {
    Severity: Minor
    Found in apps/nestjs-backend/src/features/plugin/plugin.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 getUserMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private async getUserMap(userIds: string[]) {
        const users = await this.prismaService.txClient().user.findMany({
          where: { id: { in: userIds }, deletedTime: null },
          select: {
            id: true,
    Severity: Minor
    Found in apps/nestjs-backend/src/features/plugin/plugin.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