File visitor.ts
has 319 lines of code (exceeds 300 allowed). Consider refactoring. Open
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { CellValueType } from '../models/field/constant';
import type { FieldCore } from '../models/field/field';
Function visitBinaryOp
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
visitBinaryOp(ctx: BinaryOpContext) {
const leftNode = ctx.expr(0);
const rightNode = ctx.expr(1);
const left = this.visit(leftNode)!;
const right = this.visit(rightNode)!;
- 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 transformNodeValue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private transformNodeValue(typedValue: TypedValue, ctx: BinaryOpContext) {
// A Node with a field value type requires dedicated string conversion logic to be executed.
if (!typedValue.field) {
return typedValue;
}
- 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 transformUnaryNodeValue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private transformUnaryNodeValue(typedValue: TypedValue) {
if (!typedValue.field) {
return typedValue;
}
- 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 CellValueType.String;
Avoid too many return
statements within this function. Open
return new TypedValue(field.cellValue2String(typedValue.value), CellValueType.String);
Avoid too many return
statements within this function. Open
return typedValue;
Avoid too many return
statements within this function. Open
return typedValue;
Function visitFunctionCall
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
visitFunctionCall(ctx: FunctionCallContext) {
const fnName = ctx.func_name().text.toUpperCase() as FunctionName;
const func = FUNCTIONS[fnName];
if (!func) {
throw new TypeError(`Function name ${func} is not found`);
- 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"