opensheetmusicdisplay/opensheetmusicdisplay

View on GitHub
src/OpenSheetMusicDisplay/Cursor.ts

Summary

Maintainability
D
2 days
Test Coverage

File Cursor.ts has 334 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {MusicPartManagerIterator} from "../MusicalScore/MusicParts/MusicPartManagerIterator";
import {MusicPartManager} from "../MusicalScore/MusicParts/MusicPartManager";
import {VoiceEntry} from "../MusicalScore/VoiceData/VoiceEntry";
import {VexFlowStaffEntry} from "../MusicalScore/Graphical/VexFlow/VexFlowStaffEntry";
import {MusicSystem} from "../MusicalScore/Graphical/MusicSystem";
Severity: Minor
Found in src/OpenSheetMusicDisplay/Cursor.ts - About 4 hrs to fix

    Function update has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      public update(): void {
        if (this.hidden || this.hidden === undefined || this.hidden === null) {
          return;
        }
        this.updateCurrentPage(); // attach cursor to new page DOM if necessary
    Severity: Minor
    Found in src/OpenSheetMusicDisplay/Cursor.ts - About 3 hrs 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 update has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public update(): void {
        if (this.hidden || this.hidden === undefined || this.hidden === null) {
          return;
        }
        this.updateCurrentPage(); // attach cursor to new page DOM if necessary
    Severity: Major
    Found in src/OpenSheetMusicDisplay/Cursor.ts - About 2 hrs to fix

      Cursor has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class Cursor {
        constructor(container: HTMLElement, openSheetMusicDisplay: OpenSheetMusicDisplay, cursorOptions: CursorOptions) {
          this.container = container;
          this.openSheetMusicDisplay = openSheetMusicDisplay;
          this.rules = this.openSheetMusicDisplay.EngravingRules;
      Severity: Minor
      Found in src/OpenSheetMusicDisplay/Cursor.ts - About 2 hrs to fix

        Function updateWidthAndStyle has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public updateWidthAndStyle(measurePositionAndShape: BoundingBox, x: number, y: number, height: number): void {
            const cursorElement: HTMLImageElement = this.cursorElement;
            let newWidth: number = 0;
            switch (this.cursorOptions.type) {
              case CursorType.ThinLeft:
        Severity: Minor
        Found in src/OpenSheetMusicDisplay/Cursor.ts - About 1 hr to fix

          Function updateStyle has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private updateStyle(width: number, cursorOptions: CursorOptions = undefined): void {
              if (cursorOptions !== undefined) {
                this.cursorOptions = cursorOptions;
              }
              // Create a dummy canvas to generate the gradient for the cursor
          Severity: Minor
          Found in src/OpenSheetMusicDisplay/Cursor.ts - About 1 hr to fix

            Function updateCurrentPage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              public updateCurrentPage(): number {
                let timestamp: Fraction = this.iterator.currentTimeStamp;
                if (timestamp.RealValue < 0) {
                  timestamp = new Fraction(0, 0);
                }
            Severity: Minor
            Found in src/OpenSheetMusicDisplay/Cursor.ts - About 35 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

            There are no issues that match your filters.

            Category
            Status