opensheetmusicdisplay/opensheetmusicdisplay

View on GitHub
src/MusicalScore/VoiceData/VoiceEntry.ts

Summary

Maintainability
F
1 wk
Test Coverage

File VoiceEntry.ts has 406 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {Fraction} from "../../Common/DataObjects/Fraction";
import {Voice} from "./Voice";
import {SourceStaffEntry} from "./SourceStaffEntry";
import {Note} from "./Note";
import {Pitch} from "../../Common/DataObjects/Pitch";
Severity: Minor
Found in src/MusicalScore/VoiceData/VoiceEntry.ts - About 5 hrs to fix

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

    export class VoiceEntry {
        /**
         *
         * @param timestamp The relative timestamp within the source measure.
         * @param parentVoice
    Severity: Minor
    Found in src/MusicalScore/VoiceData/VoiceEntry.ts - About 5 hrs to fix

      Function createVoiceEntriesForOrnament has 132 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public createVoiceEntriesForOrnament(voiceEntryWithOrnament: VoiceEntry, activeKey: KeyInstruction): VoiceEntry[] {
              if (!voiceEntryWithOrnament) {
                  voiceEntryWithOrnament = this;
              }
              const voiceEntries: VoiceEntry[] = [];
      Severity: Major
      Found in src/MusicalScore/VoiceData/VoiceEntry.ts - About 5 hrs to fix

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

            public createVoiceEntriesForOrnament(voiceEntryWithOrnament: VoiceEntry, activeKey: KeyInstruction): VoiceEntry[] {
                if (!voiceEntryWithOrnament) {
                    voiceEntryWithOrnament = this;
                }
                const voiceEntries: VoiceEntry[] = [];
        Severity: Minor
        Found in src/MusicalScore/VoiceData/VoiceEntry.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

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

                    case OrnamentEnum.DelayedTurn: {
                        const length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 2);
                        const lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
                        const lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
                        const higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
        Severity: Major
        Found in src/MusicalScore/VoiceData/VoiceEntry.ts and 1 other location - About 1 day to fix
        src/MusicalScore/VoiceData/VoiceEntry.ts on lines 333..350

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

        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

                    case OrnamentEnum.DelayedInvertedTurn: {
                        const length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 2);
                        const lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
                        const lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
                        const higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
        Severity: Major
        Found in src/MusicalScore/VoiceData/VoiceEntry.ts and 1 other location - About 1 day to fix
        src/MusicalScore/VoiceData/VoiceEntry.ts on lines 315..332

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

        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

                    case OrnamentEnum.Turn: {
                        const length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 4);
                        const lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
                        const lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
                        const higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
        Severity: Major
        Found in src/MusicalScore/VoiceData/VoiceEntry.ts and 1 other location - About 1 day to fix
        src/MusicalScore/VoiceData/VoiceEntry.ts on lines 296..314

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

        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

                    case OrnamentEnum.InvertedTurn: {
                        const length: Fraction = new Fraction(baselength.Numerator, baselength.Denominator * 4);
                        const lowerPitch: Pitch = baseNote.Pitch.getTransposedPitch(-1);
                        const lowerAlteration: AccidentalEnum = activeKey.getAlterationForPitch(lowerPitch);
                        const higherPitch: Pitch = baseNote.Pitch.getTransposedPitch(1);
        Severity: Major
        Found in src/MusicalScore/VoiceData/VoiceEntry.ts and 1 other location - About 1 day to fix
        src/MusicalScore/VoiceData/VoiceEntry.ts on lines 277..295

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

        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 hasSlur(): boolean {
                for (let idx: number = 0, len: number = this.Notes.length; idx < len; ++idx) {
                    const note: Note = this.Notes[idx];
                    if (note.NoteSlurs.length > 0) { return true; }
                }
        Severity: Major
        Found in src/MusicalScore/VoiceData/VoiceEntry.ts and 1 other location - About 3 hrs to fix
        src/MusicalScore/VoiceData/SourceStaffEntry.ts on lines 238..246

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

        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

            public isAccent(): boolean {
                for (const articulation of this.Articulations) {
                    if (articulation.articulationEnum === ArticulationEnum.accent || articulation.articulationEnum === ArticulationEnum.strongaccent) {
                        return true;
                    }
        Severity: Major
        Found in src/MusicalScore/VoiceData/VoiceEntry.ts and 2 other locations - About 1 hr to fix
        src/MusicalScore/VoiceData/SourceMeasure.ts on lines 564..572
        src/MusicalScore/VoiceData/SourceMeasure.ts on lines 574..582

        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 isStaccato(): boolean {
                for (const articulation of this.Articulations) {
                    if (articulation.articulationEnum === ArticulationEnum.staccato) {
                        return true;
                    }
        Severity: Minor
        Found in src/MusicalScore/VoiceData/VoiceEntry.ts and 1 other location - About 35 mins to fix
        src/MusicalScore/VoiceData/Expressions/MultiTempoExpression.ts on lines 110..118

        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