KennethanCeyer/formulize

View on GitHub

Showing 9 of 34 total issues

File ui.manager.ts has 367 lines of code (exceeds 250 allowed). Consider refactoring.
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';
Severity: Minor
Found in src/ui/ui.manager.ts - About 4 hrs to fix

    UIManager has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export abstract class UIManager extends UIPipe {
        protected prevCursorIndex = 0;
        protected prevPosition: Position = { x: 0, y: 0 };
        protected dragged: boolean;
        protected moved: boolean;
    Severity: Minor
    Found in src/ui/ui.manager.ts - About 4 hrs to fix

      Function analyzeKey has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected analyzeKey<T>(keyCode: number, pressedCtrl: boolean, pressedShift: boolean): boolean {
              const behaviors: Behavior[] = [
                  { predicate: FormulizeKeyHelper.isReload, doBehavior: FormulizeKeyHelper.doReload },
                  {
                      predicate: FormulizeKeyHelper.isSelectAll,
      Severity: Minor
      Found in src/ui/ui.ts - About 1 hr to fix

        Function getValue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        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)
        Severity: Minor
        Found in src/key.helper.ts - About 1 hr 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 findClosestUnit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private findClosestUnit(position: Position): HTMLElement {
                const unitPositions: ElementPosition[] = this.container
                    .children(`*:not(".${this.options.id}-cursor")`)
                    .toArray()
                    .map(elem => ({
        Severity: Minor
        Found in src/ui/ui.manager.ts - About 1 hr to fix

          Function insertValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public insertValue(value: string): void {
                  if (!FormulizeTokenHelper.isValid(value))
                      return;
          
                  if (FormulizeTokenHelper.isNumeric(value)) {
          Severity: Minor
          Found in src/ui/ui.manager.ts - About 55 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

          Avoid too many return statements within this function.
          Open

                      return pressedShift
                          ? specialCharacters[Number(numberValue)]
                          : numberValue;
          Severity: Major
          Found in src/key.helper.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return '/';
            Severity: Major
            Found in src/key.helper.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return undefined;
              Severity: Major
              Found in src/key.helper.ts - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language