File field.service.ts
has 508 lines of code (exceeds 300 allowed). Consider refactoring. Open
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
import type {
IFieldVo,
IGetFieldsQuery,
ISnapshotBase,
FieldService
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
@Injectable()
export class FieldService implements IReadonlyAdapterService {
constructor(
private readonly batchService: BatchService,
private readonly prismaService: PrismaService,
Function handleFieldProperty
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private async handleFieldProperty(fieldId: string, opContext: IOpContext) {
const { key, newValue } = opContext as ISetFieldPropertyOpContext;
if (key === 'options') {
if (!newValue) {
- Read upRead up
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 alterTableModifyFieldValidation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private async alterTableModifyFieldValidation(
fieldId: string,
key: 'unique' | 'notNull',
newValue?: boolean
) {
- Read upRead up
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 alterTableAddField
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private async alterTableAddField(dbTableName: string, fieldInstances: IFieldInstance[]) {
for (let i = 0; i < fieldInstances.length; i++) {
const { dbFieldType, dbFieldName, type, isLookup, unique, notNull } = fieldInstances[i];
const alterTableQuery = this.knex.schema
- Read upRead up
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 getFieldsByQuery
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async getFieldsByQuery(tableId: string, query?: IGetFieldsQuery): Promise<IFieldVo[]> {
const fieldsPlain = await this.prismaService.txClient().field.findMany({
where: { tableId, deletedTime: null },
orderBy: [
{
- Read upRead up
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 batchUpdateFields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async batchUpdateFields(tableId: string, opData: { fieldId: string; ops: IOtOperation[] }[]) {
if (!opData.length) return;
const fieldRaw = await this.prismaService.txClient().field.findMany({
where: { tableId, id: { in: opData.map((data) => data.fieldId) }, deletedTime: null },
- Read upRead up
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"