opensheetmusicdisplay/opensheetmusicdisplay

View on GitHub
src/MusicalScore/Graphical/VexFlow/AlignmentManager.ts

Summary

Maintainability
C
1 day
Test Coverage

Function alignDynamicExpressions has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    public alignDynamicExpressions(): void {
        // Find close expressions along the staffline. Group them into tuples
        const groups: AbstractGraphicalExpression[][] = [];
        let tmpList: AbstractGraphicalExpression[] = new Array<AbstractGraphicalExpression>();
        for (let aeIdx: number = 0; aeIdx < this.parentStaffline.AbstractExpressions.length - 1; aeIdx++) {
Severity: Minor
Found in src/MusicalScore/Graphical/VexFlow/AlignmentManager.ts - About 7 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 alignDynamicExpressions has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public alignDynamicExpressions(): void {
        // Find close expressions along the staffline. Group them into tuples
        const groups: AbstractGraphicalExpression[][] = [];
        let tmpList: AbstractGraphicalExpression[] = new Array<AbstractGraphicalExpression>();
        for (let aeIdx: number = 0; aeIdx < this.parentStaffline.AbstractExpressions.length - 1; aeIdx++) {
Severity: Minor
Found in src/MusicalScore/Graphical/VexFlow/AlignmentManager.ts - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                            if (prevExpression) {
                                const overlapLeft: PointF2D = this.getOverlap(prevExpression.PositionAndShape, expr.PositionAndShape);
                                (expr as VexFlowContinuousDynamicExpression).squeeze(overlapLeft.x + this.rules.DynamicExpressionSpacer);
                            }
    Severity: Major
    Found in src/MusicalScore/Graphical/VexFlow/AlignmentManager.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (nextExpression) {
                                  const overlapRight: PointF2D = this.getOverlap(expr.PositionAndShape, nextExpression.PositionAndShape);
                                  (expr as VexFlowContinuousDynamicExpression).squeeze(-(overlapRight.x + this.rules.DynamicExpressionSpacer));
                              }
      Severity: Major
      Found in src/MusicalScore/Graphical/VexFlow/AlignmentManager.ts - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status