Showing 9 of 34 total issues
File ui.manager.ts
has 367 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { convert, valid } from 'metric-parser';
import { FormulizeTokenHelper } from '../token.helper';
import { Tree } from 'metric-parser/dist/types/tree/simple.tree/type';
import { UIElementHelper } from './ui.element.helper';
import { ElementPosition, FormulizeData, Position } from './ui.interface';
UIManager
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export abstract class UIManager extends UIPipe {
protected prevCursorIndex = 0;
protected prevPosition: Position = { x: 0, y: 0 };
protected dragged: boolean;
protected moved: boolean;
Function analyzeKey
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected analyzeKey<T>(keyCode: number, pressedCtrl: boolean, pressedShift: boolean): boolean {
const behaviors: Behavior[] = [
{ predicate: FormulizeKeyHelper.isReload, doBehavior: FormulizeKeyHelper.doReload },
{
predicate: FormulizeKeyHelper.isSelectAll,
Function getValue
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
public static getValue(keyCode: number, pressedShift: boolean = false): string {
if (keyCode === Key.Multiply)
return 'x';
if (((keyCode === Key.PlusSign || keyCode === 61) && pressedShift) || keyCode === Key.Add)
- 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 findClosestUnit
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private findClosestUnit(position: Position): HTMLElement {
const unitPositions: ElementPosition[] = this.container
.children(`*:not(".${this.options.id}-cursor")`)
.toArray()
.map(elem => ({
Function insertValue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
public insertValue(value: string): void {
if (!FormulizeTokenHelper.isValid(value))
return;
if (FormulizeTokenHelper.isNumeric(value)) {
- 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
Open
return pressedShift
? specialCharacters[Number(numberValue)]
: numberValue;
Avoid too many return
statements within this function. Open
Open
return '/';
Avoid too many return
statements within this function. Open
Open
return undefined;