src/OpenSheetMusicDisplay/Cursor.ts
File Cursor.ts
has 334 lines of code (exceeds 250 allowed). Consider refactoring. Open
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";
Function update
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Open
public update(): void {
if (this.hidden || this.hidden === undefined || this.hidden === null) {
return;
}
this.updateCurrentPage(); // attach cursor to new page DOM if necessary
- 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 update
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public update(): void {
if (this.hidden || this.hidden === undefined || this.hidden === null) {
return;
}
this.updateCurrentPage(); // attach cursor to new page DOM if necessary
Cursor
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class Cursor {
constructor(container: HTMLElement, openSheetMusicDisplay: OpenSheetMusicDisplay, cursorOptions: CursorOptions) {
this.container = container;
this.openSheetMusicDisplay = openSheetMusicDisplay;
this.rules = this.openSheetMusicDisplay.EngravingRules;
Function updateWidthAndStyle
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
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:
Function updateStyle
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function updateCurrentPage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public updateCurrentPage(): number {
let timestamp: Fraction = this.iterator.currentTimeStamp;
if (timestamp.RealValue < 0) {
timestamp = new Fraction(0, 0);
}
- 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"