opensheetmusicdisplay/opensheetmusicdisplay

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

Summary

Maintainability
D
2 days
Test Coverage

GraphicalStaffEntry has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

export abstract class GraphicalStaffEntry extends GraphicalObject {
    constructor(parentMeasure: GraphicalMeasure, sourceStaffEntry: SourceStaffEntry = undefined, staffEntryParent: GraphicalStaffEntry = undefined) {
        super();
        this.parentMeasure = parentMeasure;
        this.graphicalVoiceEntries = [];
Severity: Minor
Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts - About 2 hrs to fix

    File GraphicalStaffEntry.ts has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {SourceStaffEntry} from "../VoiceData/SourceStaffEntry";
    import {BoundingBox} from "./BoundingBox";
    import {Fraction} from "../../Common/DataObjects/Fraction";
    import {VerticalGraphicalStaffEntryContainer} from "./VerticalGraphicalStaffEntryContainer";
    import {Note} from "../VoiceData/Note";
    Severity: Minor
    Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts - About 2 hrs to fix

      Function addGraphicalNoteToListAtCorrectYPosition has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public addGraphicalNoteToListAtCorrectYPosition(gve: GraphicalVoiceEntry, graphicalNote: GraphicalNote): void {
              const graphicalNotes: GraphicalNote[] = gve.notes;
              if (graphicalNotes.length === 0 ||
                  graphicalNote.PositionAndShape.RelativePosition.y < CollectionUtil.last(graphicalNotes).PositionAndShape.RelativePosition.y) {
                  graphicalNotes.push(graphicalNote);
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.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 findEndTieGraphicalNoteFromNoteWithStartingSlur has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public findEndTieGraphicalNoteFromNoteWithStartingSlur(tieNote: Note, slur: Slur): GraphicalNote {
              if (!tieNote) {
                  return undefined;
              }
              for (const gve of this.graphicalVoiceEntries) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.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 findGraphicalNoteFromGraceNote has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public findGraphicalNoteFromGraceNote(graceNote: Note): GraphicalNote {
              if (!graceNote) {
                  return undefined;
              }
              for (const gve of this.graphicalVoiceEntries) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts - About 55 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 findGraphicalNoteFromNote has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public findGraphicalNoteFromNote(note: Note): GraphicalNote {
              if (!note) {
                  return undefined;
              }
              for (const gve of this.graphicalVoiceEntries) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts - About 55 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 findTieGraphicalNoteFromNote has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public findTieGraphicalNoteFromNote(tieNote: Note): GraphicalNote {
              for (const gve of this.graphicalVoiceEntries) {
                  for (const graphicalNote of gve.notes) {
                      const note: Note = graphicalNote.sourceNote;
                      if (!note.isRest()
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.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 isVoiceEntryPartOfLinkedVoiceEntry has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public isVoiceEntryPartOfLinkedVoiceEntry(voiceEntry: VoiceEntry): boolean {
              if (this.sourceStaffEntry.Link) {
                  for (let idx: number = 0, len: number = this.sourceStaffEntry.Link.LinkStaffEntries.length; idx < len; ++idx) {
                      const sEntry: SourceStaffEntry = this.sourceStaffEntry.Link.LinkStaffEntries[idx];
                      if (sEntry.VoiceEntries.indexOf(voiceEntry) !== -1 && sEntry !== this.sourceStaffEntry) {
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.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 findStaffEntryMaxNoteLength has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public findStaffEntryMaxNoteLength(): Fraction {
              let maxLength: Fraction = new Fraction(0, 1);
              for (const gve of this.graphicalVoiceEntries) {
                  for (const graphicalNote of gve.notes) {
                      const calNoteLen: Fraction = graphicalNote.graphicalNoteLength;
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.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 findStaffEntryMinNoteLength has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public findStaffEntryMinNoteLength(): Fraction {
              let minLength: Fraction = new Fraction(Number.MAX_VALUE, 1);
              for (const gve of this.graphicalVoiceEntries) {
                  for (const graphicalNote of gve.notes) {
                      const calNoteLen: Fraction = graphicalNote.graphicalNoteLength;
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.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

              for (const gve of this.graphicalVoiceEntries) {
                  for (const graphicalNote of gve.notes) {
                      const calNoteLen: Fraction = graphicalNote.graphicalNoteLength;
                      if (maxLength.lt(calNoteLen)  && calNoteLen.GetExpandedNumerator() > 0) {
                          maxLength = calNoteLen;
      Severity: Major
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts and 1 other location - About 2 hrs to fix
      src/MusicalScore/Graphical/GraphicalStaffEntry.ts on lines 218..225

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

      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 (const gve of this.graphicalVoiceEntries) {
                  for (const graphicalNote of gve.notes) {
                      const calNoteLen: Fraction = graphicalNote.graphicalNoteLength;
                      if (calNoteLen.lt(minLength) && calNoteLen.GetExpandedNumerator() > 0) {
                          minLength = calNoteLen;
      Severity: Major
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts and 1 other location - About 2 hrs to fix
      src/MusicalScore/Graphical/GraphicalStaffEntry.ts on lines 231..238

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

      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 getBottomlineMax(): number {
              const skybottomcalculator: SkyBottomLineCalculator = this.parentMeasure?.ParentStaffLine.SkyBottomLineCalculator;
              if (!skybottomcalculator) {
                  return undefined;
              }
      Severity: Major
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts and 1 other location - About 1 hr to fix
      src/MusicalScore/Graphical/GraphicalStaffEntry.ts on lines 311..318

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

      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 getSkylineMin(): number {
              const skybottomcalculator: SkyBottomLineCalculator = this.parentMeasure?.ParentStaffLine.SkyBottomLineCalculator;
              if (!skybottomcalculator) {
                  return undefined;
              }
      Severity: Major
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts and 1 other location - About 1 hr to fix
      src/MusicalScore/Graphical/GraphicalStaffEntry.ts on lines 332..339

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

      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 getHighestYAtEntry(): number {
              const baseY: number = this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y;
              return baseY + this.getSkylineMin();
          }
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts and 1 other location - About 40 mins to fix
      src/MusicalScore/Graphical/GraphicalStaffEntry.ts on lines 327..330

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

      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 getLowestYAtEntry(): number {
              const baseY: number = this.parentMeasure.ParentStaffLine.PositionAndShape.AbsolutePosition.y;
              return baseY + this.getBottomlineMax();
          }
      Severity: Minor
      Found in src/MusicalScore/Graphical/GraphicalStaffEntry.ts and 1 other location - About 40 mins to fix
      src/MusicalScore/Graphical/GraphicalStaffEntry.ts on lines 321..324

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

      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