Showing 8 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 = {}) {
Measure
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
export class Measure {
_duration: string;
constructor(maxDuration = 64) {
this._maxDuration = maxDuration;
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;
- Read upRead up
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);
- Read upRead up
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;
- Read upRead up
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;
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) {
- Read upRead up
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');
- Read upRead up
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"