opensheetmusicdisplay/opensheetmusicdisplay

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

Summary

Maintainability
F
5 days
Test Coverage

MusicSystem has 39 functions (exceeds 20 allowed). Consider refactoring.
Open

export abstract class MusicSystem extends GraphicalObject {
    public needsToBeRedrawn: boolean = true;
    public rules: EngravingRules;
    protected parent: GraphicalMusicPage;
    protected id: number;
Severity: Minor
Found in src/MusicalScore/Graphical/MusicSystem.ts - About 5 hrs to fix

    File MusicSystem.ts has 381 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {StaffLine} from "./StaffLine";
    import {Instrument} from "../Instrument";
    import {BoundingBox} from "./BoundingBox";
    import {Fraction} from "../../Common/DataObjects/Fraction";
    import {SourceMeasure} from "../VoiceData/SourceMeasure";
    Severity: Minor
    Found in src/MusicalScore/Graphical/MusicSystem.ts - About 5 hrs to fix

      Function checkStaffEntriesForStaffEntryLink has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public checkStaffEntriesForStaffEntryLink(): boolean {
              let first: boolean = false;
              let second: boolean = false;
              for (let i: number = 0; i < this.staffLines.length - 1; i++) {
                  for (let idx: number = 0, len: number = this.staffLines[i].Measures.length; idx < len; ++idx) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystem.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 createGroupBrackets has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public createGroupBrackets(instrumentGroups: InstrumentalGroup[], staffHeight: number, recursionDepth: number): void {
              for (let idx: number = 0, len: number = instrumentGroups.length; idx < len; ++idx) {
                  const instrumentGroup: InstrumentalGroup = instrumentGroups[idx];
                  if (instrumentGroup.InstrumentalGroups.length < 1) {
                      continue;
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystem.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 createMusicSystemLabel has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public createMusicSystemLabel(  instrumentLabelTextHeight: number, systemLabelsRightMargin: number,
                                          labelMarginBorderFactor: number, isFirstSystem: boolean = false): void {
      
              const originalSystemLabelsRightMargin: number = systemLabelsRightMargin;
              for (let idx: number = 0, len: number = this.staffLines.length; idx < len; ++idx) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystem.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 createInstrumentBrackets has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public createInstrumentBrackets(instruments: Instrument[], staffHeight: number): void {
              for (let idx: number = 0, len: number = instruments.length; idx < len; ++idx) {
                  const instrument: Instrument = instruments[idx];
                  if (instrument.Staves.length > 1) {
                      let firstStaffLine: StaffLine = undefined, lastStaffLine: StaffLine = undefined;
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystem.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 createMusicSystemLabel has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public createMusicSystemLabel(  instrumentLabelTextHeight: number, systemLabelsRightMargin: number,
                                          labelMarginBorderFactor: number, isFirstSystem: boolean = false): void {
      
              const originalSystemLabelsRightMargin: number = systemLabelsRightMargin;
              for (let idx: number = 0, len: number = this.staffLines.length; idx < len; ++idx) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/MusicSystem.ts - About 1 hr to fix

        Function createGroupBrackets has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public createGroupBrackets(instrumentGroups: InstrumentalGroup[], staffHeight: number, recursionDepth: number): void {
                for (let idx: number = 0, len: number = instrumentGroups.length; idx < len; ++idx) {
                    const instrumentGroup: InstrumentalGroup = instrumentGroups[idx];
                    if (instrumentGroup.InstrumentalGroups.length < 1) {
                        continue;
        Severity: Minor
        Found in src/MusicalScore/Graphical/MusicSystem.ts - About 1 hr to fix

          Function checkStaffEntriesForStaffEntryLink has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public checkStaffEntriesForStaffEntryLink(): boolean {
                  let first: boolean = false;
                  let second: boolean = false;
                  for (let i: number = 0; i < this.staffLines.length - 1; i++) {
                      for (let idx: number = 0, len: number = this.staffLines[i].Measures.length; idx < len; ++idx) {
          Severity: Minor
          Found in src/MusicalScore/Graphical/MusicSystem.ts - About 1 hr to fix

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

                private findLastVisibleInstrumentInInstrumentalGroup(instrumentalGroup: InstrumentalGroup): Instrument {
                    let groupOrInstrument: InstrumentalGroup;
                    for (let i: number = instrumentalGroup.InstrumentalGroups.length - 1; i >= 0; i--) {
                        groupOrInstrument = instrumentalGroup.InstrumentalGroups[i];
                        if (groupOrInstrument instanceof Instrument) {
            Severity: Minor
            Found in src/MusicalScore/Graphical/MusicSystem.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 findFirstVisibleInstrumentInInstrumentalGroup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private findFirstVisibleInstrumentInInstrumentalGroup(instrumentalGroup: InstrumentalGroup): Instrument {
                    for (let idx: number = 0, len: number = instrumentalGroup.InstrumentalGroups.length; idx < len; ++idx) {
                        const groupOrInstrument: InstrumentalGroup = instrumentalGroup.InstrumentalGroups[idx];
                        if (groupOrInstrument instanceof Instrument) {
                            if ((<Instrument>groupOrInstrument).Visible === true) {
            Severity: Minor
            Found in src/MusicalScore/Graphical/MusicSystem.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

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

                    for (let idx2: number = 0, len2: number = this.InstrumentBrackets.length; idx2 < len2; ++idx2) {
                        const instrumentBracket: GraphicalObject = this.InstrumentBrackets[idx2];
                        width = Math.max(width, instrumentBracket.PositionAndShape.Size.width);
                    }
            Severity: Major
            Found in src/MusicalScore/Graphical/MusicSystem.ts and 1 other location - About 2 hrs to fix
            src/MusicalScore/Graphical/MusicSystem.ts on lines 447..450

            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 93.

            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.GroupBrackets.length; idx < len; ++idx) {
                        const groupBracket: GraphicalObject = this.GroupBrackets[idx];
                        width = Math.max(width, groupBracket.PositionAndShape.Size.width);
                    }
            Severity: Major
            Found in src/MusicalScore/Graphical/MusicSystem.ts and 1 other location - About 2 hrs to fix
            src/MusicalScore/Graphical/MusicSystem.ts on lines 451..454

            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 93.

            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 idx2: number = 0, len2: number = measure.staffEntries.length; idx2 < len2; ++idx2) {
                                const staffEntry: GraphicalStaffEntry = measure.staffEntries[idx2];
                                if (staffEntry.sourceStaffEntry.Link) {
                                    first = true;
                                }
            Severity: Major
            Found in src/MusicalScore/Graphical/MusicSystem.ts and 1 other location - About 2 hrs to fix
            src/MusicalScore/Graphical/MusicSystem.ts on lines 392..397

            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 87.

            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 idx2: number = 0, len2: number = measure.staffEntries.length; idx2 < len2; ++idx2) {
                                const staffEntry: GraphicalStaffEntry = measure.staffEntries[idx2];
                                if (staffEntry.sourceStaffEntry.Link) {
                                    second = true;
                                }
            Severity: Major
            Found in src/MusicalScore/Graphical/MusicSystem.ts and 1 other location - About 2 hrs to fix
            src/MusicalScore/Graphical/MusicSystem.ts on lines 383..388

            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 87.

            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

                public get NextSystem(): MusicSystem {
                    const idxInParent: number = this.Parent.MusicSystems.indexOf(this);
                    return idxInParent !== this.Parent.MusicSystems.length ? this.Parent.MusicSystems[idxInParent + 1] : undefined;
                }
            Severity: Major
            Found in src/MusicalScore/Graphical/MusicSystem.ts and 1 other location - About 2 hrs to fix
            src/MusicalScore/Graphical/StaffLine.ts on lines 110..113

            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 82.

            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

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

                protected createSystemLine(xPosition: number, lineWidth: number, lineType: SystemLinesEnum, linePosition: SystemLinePosition,
                                           musicSystem: MusicSystem, topMeasure: GraphicalMeasure, bottomMeasure: GraphicalMeasure = undefined): SystemLine {
                    throw new Error("not implemented");
                }
            Severity: Minor
            Found in src/MusicalScore/Graphical/MusicSystem.ts and 1 other location - About 45 mins to fix
            src/MusicalScore/Graphical/VexFlow/VexFlowMusicSystem.ts on lines 57..83

            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 50.

            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