opensheetmusicdisplay/opensheetmusicdisplay

View on GitHub
src/MusicalScore/Graphical/MusicSystemBuilder.ts

Summary

Maintainability
F
1 wk
Test Coverage

File MusicSystemBuilder.ts has 976 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {GraphicalMeasure} from "./GraphicalMeasure";
import {GraphicalMusicPage} from "./GraphicalMusicPage";
import {EngravingRules} from "./EngravingRules";
import {RhythmInstruction} from "../VoiceData/Instructions/RhythmInstruction";
import {KeyInstruction} from "../VoiceData/Instructions/KeyInstruction";
Severity: Major
Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 2 days to fix

    Function buildMusicSystems has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

        public buildMusicSystems(): MusicSystem[] {
            const systemMaxWidth: number = this.getFullPageSystemWidth();
            let prevMeasureEndsPart: boolean = false;
            this.measureListIndex = 0;
            this.currentSystemParams = new SystemBuildParameters();
    Severity: Minor
    Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 6 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

    MusicSystemBuilder has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class MusicSystemBuilder {
        protected measureList: GraphicalMeasure[][];
        protected graphicalMusicSheet: GraphicalMusicSheet;
        protected currentSystemParams: SystemBuildParameters;
        protected numberOfVisibleStaffLines: number;
    Severity: Minor
    Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 5 hrs to fix

      Function updateActiveClefs has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

          protected updateActiveClefs(measure: SourceMeasure, graphicalMeasures: GraphicalMeasure[]): void {
              for (let visStaffIdx: number = 0, len: number = graphicalMeasures.length; visStaffIdx < len; visStaffIdx++) {
                  const staffIndex: number = this.visibleStaffIndices[visStaffIdx];
                  const firstEntry: SourceStaffEntry = measure.FirstInstructionsStaffEntries[staffIndex];
                  if (firstEntry) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 5 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 AddInstructionsAtMeasureBegin has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          protected AddInstructionsAtMeasureBegin(firstEntry: SourceStaffEntry, measure: GraphicalMeasure,
                                                  visibleStaffIdx: number, isFirstSourceMeasure: boolean, isSystemStartMeasure: boolean): number {
              let instructionsLengthX: number = 0;
              let currentClef: ClefInstruction = undefined;
              let currentKey: KeyInstruction = undefined;
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 5 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 stretchMusicSystem has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          protected stretchMusicSystem(systemEndsPart: boolean): void {
              let scalingFactor: number = this.calculateXScalingFactor(
                  this.currentSystemParams.currentSystemFixWidth, this.currentSystemParams.currentSystemVarWidth
              );
              if (systemEndsPart) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 4 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 calculateMusicSystemsRelativePositions has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          protected calculateMusicSystemsRelativePositions(): void {
              let currentPage: GraphicalMusicPage = this.createMusicPage();
              let currentYPosition: number = 0;
              // xPosition is always fixed
              let currentSystem: MusicSystem = this.musicSystems[0];
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystemBuilder.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 buildMusicSystems has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public buildMusicSystems(): MusicSystem[] {
              const systemMaxWidth: number = this.getFullPageSystemWidth();
              let prevMeasureEndsPart: boolean = false;
              this.measureListIndex = 0;
              this.currentSystemParams = new SystemBuildParameters();
      Severity: Major
      Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 3 hrs to fix

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

            protected layoutSystemStaves(musicSystem: MusicSystem): void {
                const systemWidth: number = this.getFullPageSystemWidth();
                const boundingBox: BoundingBox = musicSystem.PositionAndShape;
                boundingBox.BorderLeft = 0.0;
                boundingBox.BorderRight = systemWidth;
        Severity: Minor
        Found in src/MusicalScore/Graphical/MusicSystemBuilder.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 AddInstructionsAtMeasureBegin has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected AddInstructionsAtMeasureBegin(firstEntry: SourceStaffEntry, measure: GraphicalMeasure,
                                                    visibleStaffIdx: number, isFirstSourceMeasure: boolean, isSystemStartMeasure: boolean): number {
                let instructionsLengthX: number = 0;
                let currentClef: ClefInstruction = undefined;
                let currentKey: KeyInstruction = undefined;
        Severity: Major
        Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 2 hrs to fix

          Function calculateMusicSystemsRelativePositions has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected calculateMusicSystemsRelativePositions(): void {
                  let currentPage: GraphicalMusicPage = this.createMusicPage();
                  let currentYPosition: number = 0;
                  // xPosition is always fixed
                  let currentSystem: MusicSystem = this.musicSystems[0];
          Severity: Major
          Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 2 hrs to fix

            Function checkAndCreateExtraInstructionMeasure has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                protected checkAndCreateExtraInstructionMeasure(measures: GraphicalMeasure[]): void {
                    const firstStaffEntries: SourceStaffEntry[] = measures[0].parentSourceMeasure.FirstInstructionsStaffEntries;
                    const visibleInstructionEntries: SourceStaffEntry[] = [];
                    for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
                        const measure: GraphicalMeasure = measures[idx];
            Severity: Minor
            Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 2 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 stretchMusicSystem has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected stretchMusicSystem(systemEndsPart: boolean): void {
                    let scalingFactor: number = this.calculateXScalingFactor(
                        this.currentSystemParams.currentSystemFixWidth, this.currentSystemParams.currentSystemVarWidth
                    );
                    if (systemEndsPart) {
            Severity: Major
            Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 2 hrs to fix

              Function layoutSystemStaves has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected layoutSystemStaves(musicSystem: MusicSystem): void {
                      const systemWidth: number = this.getFullPageSystemWidth();
                      const boundingBox: BoundingBox = musicSystem.PositionAndShape;
                      boundingBox.BorderLeft = 0.0;
                      boundingBox.BorderRight = systemWidth;
              Severity: Minor
              Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 1 hr to fix

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

                    protected updateActiveClefs(measure: SourceMeasure, graphicalMeasures: GraphicalMeasure[]): void {
                        for (let visStaffIdx: number = 0, len: number = graphicalMeasures.length; visStaffIdx < len; visStaffIdx++) {
                            const staffIndex: number = this.visibleStaffIndices[visStaffIdx];
                            const firstEntry: SourceStaffEntry = measure.FirstInstructionsStaffEntries[staffIndex];
                            if (firstEntry) {
                Severity: Minor
                Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 1 hr to fix

                  Function checkAndCreateExtraInstructionMeasure has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected checkAndCreateExtraInstructionMeasure(measures: GraphicalMeasure[]): void {
                          const firstStaffEntries: SourceStaffEntry[] = measures[0].parentSourceMeasure.FirstInstructionsStaffEntries;
                          const visibleInstructionEntries: SourceStaffEntry[] = [];
                          for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
                              const measure: GraphicalMeasure = measures[idx];
                  Severity: Minor
                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 1 hr to fix

                    Function thisMeasureEndsLineRepetition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected thisMeasureEndsLineRepetition(): boolean {
                            for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
                                const measure: GraphicalMeasure = this.measureList[this.measureListIndex][idx];
                                if (measure.endsWithLineRepetition()) {
                                    return true;
                    Severity: Minor
                    Found in src/MusicalScore/Graphical/MusicSystemBuilder.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 addInstructionsAtMeasureEnd has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected addInstructionsAtMeasureEnd(lastEntry: SourceStaffEntry, measure: GraphicalMeasure,
                            measures: GraphicalMeasure[]): number {
                            if (!lastEntry || !lastEntry.Instructions || lastEntry.Instructions.length === 0) {
                                return 0;
                            }
                    Severity: Minor
                    Found in src/MusicalScore/Graphical/MusicSystemBuilder.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 findRequiredDistanceWithSkyBottomLine has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private findRequiredDistanceWithSkyBottomLine(upperSystem: MusicSystem, lowerSystem: MusicSystem): number {
                            const upperSystemLastStaffLine: StaffLine = upperSystem.StaffLines[upperSystem.StaffLines.length - 1];
                            const lowerSystemFirstStaffLine: StaffLine = lowerSystem.StaffLines[0];
                            const upperBottomLineArray: number[] = upperSystemLastStaffLine.BottomLine;
                            const lowerSkyLineArray: number[] = lowerSystemFirstStaffLine.SkyLine;
                    Severity: Minor
                    Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 1 hr to fix

                      Function getMeasureEndLine has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected getMeasureEndLine(): SystemLinesEnum {
                              let sourceMeasure: SourceMeasure = undefined;
                              try {
                                  sourceMeasure = this.measureList[this.measureListIndex][0].parentSourceMeasure;
                                  if (this.rules.RenderMultipleRestMeasures && sourceMeasure.multipleRestMeasures > 1) {
                      Severity: Minor
                      Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 1 hr to fix

                        Function optimizeDistanceBetweenStaffLines has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected optimizeDistanceBetweenStaffLines(musicSystem: MusicSystem): void {
                                // don't perform any y-spacing in case of a StaffEntryLink (in both StaffLines)
                                if (!musicSystem.checkStaffEntriesForStaffEntryLink()) {
                                    for (let i: number = 0; i < musicSystem.StaffLines.length - 1; i++) {
                                        const upperBottomLine: number[] = musicSystem.StaffLines[i].BottomLine;
                        Severity: Minor
                        Found in src/MusicalScore/Graphical/MusicSystemBuilder.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 optimizeDistanceBetweenStaffLines has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected optimizeDistanceBetweenStaffLines(musicSystem: MusicSystem): void {
                                // don't perform any y-spacing in case of a StaffEntryLink (in both StaffLines)
                                if (!musicSystem.checkStaffEntriesForStaffEntryLink()) {
                                    for (let i: number = 0; i < musicSystem.StaffLines.length - 1; i++) {
                                        const upperBottomLine: number[] = musicSystem.StaffLines[i].BottomLine;
                        Severity: Minor
                        Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 1 hr to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if (measureIndex === 0) {
                                                          xPosition = currentXPosition + measure.beginInstructionsWidth - lineWidth;
                                                      }
                          Severity: Major
                          Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if (abstractNotationInstruction instanceof ClefInstruction) {
                                                        this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
                                                    }
                            Severity: Major
                            Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 45 mins to fix

                              Function findRequiredDistanceWithSkyBottomLine has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private findRequiredDistanceWithSkyBottomLine(upperSystem: MusicSystem, lowerSystem: MusicSystem): number {
                                      const upperSystemLastStaffLine: StaffLine = upperSystem.StaffLines[upperSystem.StaffLines.length - 1];
                                      const lowerSystemFirstStaffLine: StaffLine = lowerSystem.StaffLines[0];
                                      const upperBottomLineArray: number[] = upperSystemLastStaffLine.BottomLine;
                                      const lowerSkyLineArray: number[] = lowerSystemFirstStaffLine.SkyLine;
                              Severity: Minor
                              Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 45 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

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

                                  protected getMeasureEndLine(): SystemLinesEnum {
                                      let sourceMeasure: SourceMeasure = undefined;
                                      try {
                                          sourceMeasure = this.measureList[this.measureListIndex][0].parentSourceMeasure;
                                          if (this.rules.RenderMultipleRestMeasures && sourceMeasure.multipleRestMeasures > 1) {
                              Severity: Minor
                              Found in src/MusicalScore/Graphical/MusicSystemBuilder.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

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

                                  protected getMeasureStartLine(): SystemLinesEnum {
                                      const thisMeasureBeginsLineRep: boolean = this.thisMeasureBeginsLineRepetition();
                                      if (thisMeasureBeginsLineRep) {
                                          const isGlobalFirstMeasure: boolean = this.measureListIndex === 0;
                                          if (isGlobalFirstMeasure && this.rules.RepetitionAllowFirstMeasureBeginningRepeatBarline) {
                              Severity: Minor
                              Found in src/MusicalScore/Graphical/MusicSystemBuilder.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

                              Avoid too many return statements within this function.
                              Open

                                          return sourceMeasure.endingBarStyleEnum;
                              Severity: Major
                              Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return SystemLinesEnum.SingleThin;
                                Severity: Major
                                Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 30 mins to fix

                                  Function getNextMeasureKeyInstruction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected getNextMeasureKeyInstruction(): KeyInstruction {
                                          if (this.measureListIndex < this.measureList.length - 1) {
                                              for (let visIndex: number = 0; visIndex < this.measureList[this.measureListIndex].length; visIndex++) {
                                                  const sourceMeasure: SourceMeasure = this.measureList[this.measureListIndex + 1][visIndex]?.parentSourceMeasure;
                                                  if (!sourceMeasure) {
                                  Severity: Minor
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 25 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

                                  Function addStaffLineToMusicSystem has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected addStaffLineToMusicSystem(musicSystem: MusicSystem, relativeYPosition: number, staff: Staff): void {
                                          if (musicSystem) {
                                              const staffLine: StaffLine = MusicSheetCalculator.symbolFactory.createStaffLine(musicSystem, staff);
                                              musicSystem.StaffLines.push(staffLine);
                                              const boundingBox: BoundingBox = staffLine.PositionAndShape;
                                  Severity: Minor
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 25 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

                                  Function initializeActiveInstructions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      protected initializeActiveInstructions(measureList: GraphicalMeasure[]): void {
                                          const firstSourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
                                          if (firstSourceMeasure) {
                                              this.visibleStaffIndices = this.graphicalMusicSheet.getVisibleStavesIndicesFromSourceMeasure(measureList);
                                              for (let i: number = 0, len: number = this.visibleStaffIndices.length; i < len; i++) {
                                  Severity: Minor
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts - About 25 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

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      protected thisMeasureBeginsLineRepetition(): boolean {
                                          for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
                                              const measure: GraphicalMeasure = this.measureList[this.measureListIndex][idx];
                                              if (measure.beginsWithLineRepetition()) {
                                                  return true;
                                  Severity: Major
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts and 1 other location - About 4 hrs to fix
                                  src/MusicalScore/Graphical/MusicSystemBuilder.ts on lines 902..910

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 117.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                      protected thisMeasureEndsWordRepetition(): boolean {
                                          for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
                                              const measure: GraphicalMeasure = this.measureList[this.measureListIndex][idx];
                                              if (measure.endsWithWordRepetition()) {
                                                  return true;
                                  Severity: Major
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts and 1 other location - About 4 hrs to fix
                                  src/MusicalScore/Graphical/MusicSystemBuilder.ts on lines 820..828

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 117.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                          for (let idx: number = 0, len: number = this.measureList[nextMeasureIndex].length; idx < len; ++idx) {
                                              const measure: GraphicalMeasure = this.measureList[nextMeasureIndex][idx];
                                              if (measure.beginsWithLineRepetition()) {
                                                  return true;
                                              }
                                  Severity: Major
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts and 1 other location - About 2 hrs to fix
                                  src/MusicalScore/Graphical/MusicSystemBuilder.ts on lines 889..894

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 90.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                          for (let idx: number = 0, len: number = this.measureList[nextMeasureIndex].length; idx < len; ++idx) {
                                              const measure: GraphicalMeasure = this.measureList[nextMeasureIndex][idx];
                                              if (measure.beginsWithWordRepetition()) {
                                                  return true;
                                              }
                                  Severity: Major
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts and 1 other location - About 2 hrs to fix
                                  src/MusicalScore/Graphical/MusicSystemBuilder.ts on lines 840..845

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 90.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 3 locations. Consider refactoring.
                                  Open

                                              for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
                                                  const measure: GraphicalMeasure = measures[idx];
                                                  measure.endInstructionsWidth -= diff;
                                              }
                                  Severity: Major
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts and 2 other locations - About 1 hr to fix
                                  src/MusicalScore/ScoreIO/MusicSheetReader.ts on lines 298..301
                                  src/MusicalScore/ScoreIO/MusicSheetReader.ts on lines 313..316

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 68.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                              for (let lowerIdx: number = startIdx; lowerIdx <= endIdx; lowerIdx++) {
                                                  skylineValue = Math.min(skylineValue, lowerSkyLineArray[lowerIdx]);
                                              }
                                  Severity: Minor
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts and 1 other location - About 35 mins to fix
                                  src/MusicalScore/Graphical/MusicSystemBuilder.ts on lines 1089..1091

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 47.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                                      for (let lowerIdx: number = startIdx; lowerIdx <= endIdx; lowerIdx++) {
                                                          skylineValue = Math.min(skylineValue, lowerSkyLine[lowerIdx]);
                                                      }
                                  Severity: Minor
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts and 1 other location - About 35 mins to fix
                                  src/MusicalScore/Graphical/MusicSystemBuilder.ts on lines 1271..1273

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 47.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  Similar blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                              for (let i: number = 0; i < graphicalMeasures.length; i++) {
                                                  gmeasures.push(graphicalMeasures[i]);
                                              }
                                  Severity: Minor
                                  Found in src/MusicalScore/Graphical/MusicSystemBuilder.ts and 1 other location - About 35 mins to fix
                                  src/Util/CollectionUtil.ts on lines 87..89

                                  Duplicated Code

                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                  Tuning

                                  This issue has a mass of 46.

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  There are no issues that match your filters.

                                  Category
                                  Status