Seanitzel/Note-Art

View on GitHub

Showing 10 of 10 total issues

Score has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

export class Score {
  measureSize: number;
  timeSignature: [number, number];

  constructor({ bpm, timeSignature, name, voiceNames = [] }: ScoreProps = {}) {
Severity: Minor
Found in src/notation/Score.ts - About 3 hrs to fix

    Measure has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Measure {
      _duration: string;
    
      constructor(maxDuration = 64) {
        this._maxDuration = maxDuration;
    Severity: Minor
    Found in src/notation/Measure.ts - About 2 hrs to fix

      Function pitchClassesToPianoChordNotes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export function pitchClassesToPianoChordNotes(pitchClasses: Array<PitchClass>, octave: number, inversion = 0): Array<Note> {
        if(inversion) {
          pitchClasses = rearrangeArray(pitchClasses, inversion) as Array<PitchClass>;
        }
        let currentOctave = octave;
      Severity: Minor
      Found in src/utilities/MusicFunctions.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 transposePitchClass has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      export function transposePitchClass(pitchClass: PitchClass, interval: number): PitchClass {
        const normalizedInterval = interval % NUMBER_OF_PITCH_CLASSES;
        const normalizedPitchClass: PitchClass = normalizePitchClass(pitchClass);
        const classSet = getClassSet(pitchClass);
        const classIndex = getPitchClassSet(classSet).indexOf(normalizedPitchClass);
      Severity: Minor
      Found in src/Theory.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 normalizePitchClass has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      export function normalizePitchClass(pc: PitchClass): PitchClass {
        const pitchLetter: PitchClassLetter = firstToUpper(pc[0]) as PitchClassLetter;
        const accidental: Accidental = pc[1] as Accidental;
      
        let times, index, accurateIndex;
      Severity: Minor
      Found in src/utilities/PureMusicUtils.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 pitchClassesToPianoChordNotes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function pitchClassesToPianoChordNotes(pitchClasses: Array<PitchClass>, octave: number, inversion = 0): Array<Note> {
        if(inversion) {
          pitchClasses = rearrangeArray(pitchClasses, inversion) as Array<PitchClass>;
        }
        let currentOctave = octave;
      Severity: Minor
      Found in src/utilities/MusicFunctions.ts - About 1 hr to fix

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

        export function freqFromMidi(midi: number): number {
          return PITCH_STANDARD.frequency * Math.pow(2, (midi - PITCH_STANDARD.midi) / NUMBER_OF_PITCH_CLASSES);
        }
        Severity: Major
        Found in src/utilities/ScientificFunctions.ts and 1 other location - About 1 hr to fix
        src/utilities/ScientificFunctions.ts on lines 70..72

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

        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

        export function midiToFreq(realNumber: number): number {
          return PITCH_STANDARD.frequency * (Math.pow(2, (realNumber - PITCH_STANDARD.midi) / NUMBER_OF_PITCH_CLASSES));
        }
        Severity: Major
        Found in src/utilities/ScientificFunctions.ts and 1 other location - About 1 hr to fix
        src/utilities/ScientificFunctions.ts on lines 33..35

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

        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

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

        export function mapString(str: string, toMap: string, mapTo: string): string {
          while (str.includes(toMap)) {
            const length = str.length;
            for(let i = 0; i < length; ++i) {
              if(str.substring(i, i + toMap.length) === toMap) {
        Severity: Minor
        Found in src/utilities/GeneralFunctions.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 normalizeNote has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function normalizeNote(note: Note): Note {
          const { pitchClass, octave } = noteToObject(note);
          const normalizedPitchClass = normalizePitchClass(pitchClass);
          let octaveDifference = 0;
          const bWithSharps = pitchClass[0] === 'B' && pitchClass.includes('#' || 'x');
        Severity: Minor
        Found in src/utilities/PureMusicUtils.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

        Severity
        Category
        Status
        Source
        Language