File field-converting.service.ts
has 988 lines of code (exceeds 300 allowed). Consider refactoring. Open
import {
BadRequestException,
Injectable,
InternalServerErrorException,
Logger,
FieldConvertingService
has 43 functions (exceeds 20 allowed). Consider refactoring. Open
@Injectable()
export class FieldConvertingService {
private readonly logger = new Logger(FieldConvertingService.name);
constructor(
Function updateLookupField
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private updateLookupField(field: IFieldInstance, fieldMap: IFieldMap): IOtOperation[] {
const ops: (IOtOperation | undefined)[] = [];
const lookupOptions = field.lookupOptions as ILookupOptionsVo;
const linkField = fieldMap[lookupOptions.linkFieldId] as LinkFieldDto;
const lookupField = fieldMap[lookupOptions.lookupFieldId];
- 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
Consider simplifying this complex logical expression. Open
if (
oldField.type !== FieldType.LongText &&
newField.type !== FieldType.Rating &&
newField.cellValueType === oldField.cellValueType &&
newField.isMultipleCellValue !== true &&
Function updateOptionsFromMultiSelectField
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private async updateOptionsFromMultiSelectField(
tableId: string,
updatedChoiceMap: { [old: string]: string | null },
field: MultipleSelectFieldDto
): Promise<IOpsMap | undefined> {
- 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 getDerivateByLink
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private async getDerivateByLink(tableId: string, innerOpsMap: IOpsMap['key']) {
const changes: ICellContext[] = [];
for (const recordId in innerOpsMap) {
for (const op of innerOpsMap[recordId]) {
const context = RecordOpBuilder.editor.setRecord.detect(op);
- 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
Avoid too many return
statements within this function. Open
return this.basalConvert(tableId, newField, oldField);
Function shouldUpdateReference
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private shouldUpdateReference(newField: IFieldInstance, oldField: IFieldInstance) {
const keys = this.getOriginFieldKeys(newField, oldField);
// lookup options change
if (newField.isLookup && oldField.isLookup) {
- 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 updateOptionsFromUserField
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private async updateOptionsFromUserField(
tableId: string,
field: UserFieldDto
): Promise<IOpsMap | undefined> {
const { dbTableName } = await this.prismaService.txClient().tableMeta.findFirstOrThrow({
- 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 generateReferenceFieldOps
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private async generateReferenceFieldOps(fieldId: string) {
const topoOrdersContext = await this.fieldCalculationService.getTopoOrdersContext([fieldId]);
const { fieldMap, topoOrdersByFieldId, fieldId2TableId } = topoOrdersContext;
const topoOrders = topoOrdersByFieldId[fieldId];
- 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"