Function addTuplet
has a Cognitive Complexity of 252 (exceeds 5 allowed). Consider refactoring. Open
private addTuplet(node: IXmlElement, tupletNodeList: IXmlElement[]): number {
let bracketed: boolean = false; // true if bracket=yes given, otherwise false
let bracketedXmlValue: boolean = undefined; // Exact xml bracket value given: true for bracket=yes, false for bracket=no, undefined if not given.
// TODO refactor this to not duplicate lots of code for the cases tupletNodeList.length == 1 and > 1
if (tupletNodeList !== undefined && tupletNodeList.length > 1) {
- 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
File VoiceGenerator.ts
has 934 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { LinkedVoice } from "../VoiceData/LinkedVoice";
import { Voice } from "../VoiceData/Voice";
import { MusicSheet } from "../MusicSheet";
import { VoiceEntry, StemDirectionType } from "../VoiceData/VoiceEntry";
import { Note, TremoloInfo } from "../VoiceData/Note";
Function addSingleNote
has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring. Open
private addSingleNote(node: IXmlElement, noteDuration: Fraction, noteTypeXml: NoteType, typeDuration: Fraction,
normalNotes: number, chord: boolean, octavePlusOne: boolean,
printObject: boolean, isCueNote: boolean, isGraceNote: boolean, stemDirectionXml: StemDirectionType, tremoloInfo: TremoloInfo,
stemColorXml: string, noteheadColorXml: string, vibratoStrokes: boolean): Note {
//log.debug("addSingleNote called");
- 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 read
has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring. Open
public read(noteNode: IXmlElement, noteDuration: Fraction, typeDuration: Fraction, noteTypeXml: NoteType, normalNotes: number, restNote: boolean,
parentStaffEntry: SourceStaffEntry, parentMeasure: SourceMeasure,
measureStartAbsoluteTimestamp: Fraction, maxTieNoteFraction: Fraction, chord: boolean, octavePlusOne: boolean,
printObject: boolean, isCueNote: boolean, isGraceNote: boolean, stemDirectionXml: StemDirectionType, tremoloInfo: TremoloInfo,
stemColorXml: string, noteheadColorXml: string, vibratoStrokes: boolean,
- 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 addTuplet
has 221 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addTuplet(node: IXmlElement, tupletNodeList: IXmlElement[]): number {
let bracketed: boolean = false; // true if bracket=yes given, otherwise false
let bracketedXmlValue: boolean = undefined; // Exact xml bracket value given: true for bracket=yes, false for bracket=no, undefined if not given.
// TODO refactor this to not duplicate lots of code for the cases tupletNodeList.length == 1 and > 1
if (tupletNodeList !== undefined && tupletNodeList.length > 1) {
Function addSingleNote
has 171 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addSingleNote(node: IXmlElement, noteDuration: Fraction, noteTypeXml: NoteType, typeDuration: Fraction,
normalNotes: number, chord: boolean, octavePlusOne: boolean,
printObject: boolean, isCueNote: boolean, isGraceNote: boolean, stemDirectionXml: StemDirectionType, tremoloInfo: TremoloInfo,
stemColorXml: string, noteheadColorXml: string, vibratoStrokes: boolean): Note {
//log.debug("addSingleNote called");
Function addTie
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
private addTie(tieNodeList: IXmlElement[], measureStartAbsoluteTimestamp: Fraction, maxTieNoteFraction: Fraction, tieType: TieTypes): void {
if (tieNodeList) {
if (tieNodeList.length === 1) {
const tieNode: IXmlElement = tieNodeList[0];
if (tieNode !== undefined && tieNode.attributes()) {
- 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 read
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
public read(noteNode: IXmlElement, noteDuration: Fraction, typeDuration: Fraction, noteTypeXml: NoteType, normalNotes: number, restNote: boolean,
parentStaffEntry: SourceStaffEntry, parentMeasure: SourceMeasure,
measureStartAbsoluteTimestamp: Fraction, maxTieNoteFraction: Fraction, chord: boolean, octavePlusOne: boolean,
printObject: boolean, isCueNote: boolean, isGraceNote: boolean, stemDirectionXml: StemDirectionType, tremoloInfo: TremoloInfo,
stemColorXml: string, noteheadColorXml: string, vibratoStrokes: boolean,
Function createBeam
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private createBeam(node: IXmlElement, note: Note): void {
try {
const beamNode: IXmlElement = node.element("beam");
let beamAttr: IXmlAttribute = undefined;
if (beamNode !== undefined && beamNode.hasAttributes) {
- 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 handleOpenBeam
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private handleOpenBeam(): void {
const openBeam: Beam = this.openBeams.last();
if (openBeam.Notes.length === 0) {
// TODO why is there such a beam? sample: test_percussion_display_step_from_xml
this.endBeam(); // otherwise beamLastNote.ParentStaffEntry will throw an undefined error
- 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
VoiceGenerator
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
export class VoiceGenerator {
constructor(pluginManager: ReaderPluginManager, staff: Staff, voiceId: number, slurReader: SlurReader, mainVoice: Voice = undefined) {
this.staff = staff;
this.instrument = staff.ParentInstrument;
this.musicSheet = this.instrument.GetMusicSheet;
Function createBeam
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private createBeam(node: IXmlElement, note: Note): void {
try {
const beamNode: IXmlElement = node.element("beam");
let beamAttr: IXmlAttribute = undefined;
if (beamNode !== undefined && beamNode.hasAttributes) {
Function addTie
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addTie(tieNodeList: IXmlElement[], measureStartAbsoluteTimestamp: Fraction, maxTieNoteFraction: Fraction, tieType: TieTypes): void {
if (tieNodeList) {
if (tieNodeList.length === 1) {
const tieNode: IXmlElement = tieNodeList[0];
if (tieNode !== undefined && tieNode.attributes()) {
Function handleOpenBeam
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private handleOpenBeam(): void {
const openBeam: Beam = this.openBeams.last();
if (openBeam.Notes.length === 0) {
// TODO why is there such a beam? sample: test_percussion_display_step_from_xml
this.endBeam(); // otherwise beamLastNote.ParentStaffEntry will throw an undefined error
Function findCurrentNoteInTieDict
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private findCurrentNoteInTieDict(candidateNote: Note): number {
const openTieDict: { [_: number]: Tie } = this.openTieDict;
for (const key in openTieDict) {
if (openTieDict.hasOwnProperty(key)) {
const tie: Tie = openTieDict[key];
- 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 handleTimeModificationNode
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private handleTimeModificationNode(noteNode: IXmlElement): void {
if (this.tupletDict[this.openTupletNumber]) {
try {
// Tuplet should already be created
const tuplet: Tuplet = this.tupletDict[this.openTupletNumber];
Function handleTimeModificationNode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private handleTimeModificationNode(noteNode: IXmlElement): void {
if (this.tupletDict[this.openTupletNumber]) {
try {
// Tuplet should already be created
const tuplet: Tuplet = this.tupletDict[this.openTupletNumber];
- 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
Avoid deeply nested control flow statements. Open
if (timeModNode) {
tupletLabelNumber = parseInt(timeModNode.value, 10);
if (isNaN(tupletLabelNumber)) {
const errorMsg: string = ITextTranslation.translateText(
"ReaderErrorMessages/TupletNoteDurationError", "Invalid tuplet note duration."
Avoid deeply nested control flow statements. Open
if (placementAttr) {
if (placementAttr.value === "below") {
tuplet.tupletLabelNumberPlacement = PlacementEnum.Below;
}
tuplet.PlacementFromXml = true;
Avoid deeply nested control flow statements. Open
} else if (type === "stop") {
const tieNumber: number = this.findCurrentNoteInTieDict(this.currentNote);
const tie: Tie = this.openTieDict[tieNumber];
if (tie) {
tie.AddNote(this.currentNote);
Avoid deeply nested control flow statements. Open
if (octave) {
noteOctave = parseInt(octave.value, 10);
displayOctaveUnpitched = noteOctave - 3;
if (octavePlusOne) {
noteOctave += 1;
Avoid deeply nested control flow statements. Open
if (num < 0) {
delete this.openTieDict[num];
}
Avoid deeply nested control flow statements. Open
if (placementAttr) {
if (placementAttr.value === "below") {
tuplet.tupletLabelNumberPlacement = PlacementEnum.Below;
} else {
//Just in case
Avoid deeply nested control flow statements. Open
} else if (noteElement.name === "instrument") {
if (noteElement.firstAttribute) {
playbackInstrumentId = noteElement.firstAttribute.value;
}
} else if (noteElement.name === "notehead") {
Avoid deeply nested control flow statements. Open
if (timeModNode) {
timeModNode = timeModNode.element("actual-notes");
}
Avoid deeply nested control flow statements. Open
} else if (type === "stop") {
if (noTupletNumbering) {
tupletnumber = this.openTupletNumber;
}
const tuplet: Tuplet = this.tupletDict[this.openTupletNumber];
Avoid deeply nested control flow statements. Open
if (directionAttr) {
switch (directionAttr.value) {
case "up":
arpeggioType = ArpeggioType.ROLL_UP;
break;
Avoid deeply nested control flow statements. Open
if (voiceEntry.ParentVoice === this.voice) {
const candidateNote: Note = voiceEntry.Notes[0];
if (candidateNote.Length.lte(new Fraction(1, 8))) {
this.openBeams.last().addNoteToBeam(candidateNote);
this.endBeam();
Avoid deeply nested control flow statements. Open
if (displayStepElement) {
noteStep = NoteEnum[displayStepElement.value.toUpperCase()];
let octaveShift: number = 0;
let noteValueShift: number = this.musicSheet.Rules.PercussionXMLDisplayStepNoteValueShift;
if (this.instrument.Staves[0].StafflineCount === 1) {
Avoid deeply nested control flow statements. Open
if (tupletNode.attribute("number")) {
tupletNumber = parseInt(tupletNode.attribute("number").value, 10);
}
Function getTieDirection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private getTieDirection(tieNode: IXmlElement): PlacementEnum {
let tieDirection: PlacementEnum = PlacementEnum.NotYetDefined;
// read tie direction/placement from XML
const placementAttr: IXmlAttribute = tieNode.attribute("placement");
if (placementAttr) {
- 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
Avoid deeply nested control flow statements. Open
} else if (type.value === "stop") {
let tupletNumber: number = 1;
if (tupletNode.attribute("number")) {
tupletNumber = parseInt(tupletNode.attribute("number").value, 10);
}
Avoid deeply nested control flow statements. Open
if (noTupletNumbering) {
this.openTupletNumber++;
tupletnumber = this.openTupletNumber;
}
Avoid deeply nested control flow statements. Open
if (!tuplet) {
tuplet = this.tupletDict[tupletnumber] = new Tuplet(tupletLabelNumber, bracketed);
tuplet.BracketedXmlValue = bracketedXmlValue;
tuplet.ShowNumberNoneGivenInXml = showNumberNoneGiven;
//Default to above
Avoid deeply nested control flow statements. Open
if (voiceEntry.Arpeggio) {
arpeggioAlreadyExists = true;
currentArpeggio = voiceEntry.Arpeggio;
// TODO handle multiple arpeggios across multiple voices at same timestamp
Avoid deeply nested control flow statements. Open
for (const tieNode of tieNodeList) {
const type: string = tieNode.attribute("type").value;
if (type === "start") {
const placement: PlacementEnum = this.getTieDirection(tieNode);
tie.NoteIndexToTieDirection[tie.Notes.length - 1] = placement;
Avoid deeply nested control flow statements. Open
} else if (pitchElement.name === "alter") {
noteAlter = parseFloat(pitchElement.value);
if (isNaN(noteAlter)) {
const errorMsg: string = ITextTranslation.translateText(
"ReaderErrorMessages/NoteAlterationError", "Invalid alteration while reading note."
Avoid deeply nested control flow statements. Open
if (noteStep === undefined) { // don't replace undefined check
const errorMsg: string = ITextTranslation.translateText(
"ReaderErrorMessages/NotePitchError",
"Invalid pitch while reading note."
);
Avoid deeply nested control flow statements. Open
if (timeModNode) {
tupletLabelNumber = parseInt(timeModNode.value, 10);
if (isNaN(tupletLabelNumber)) {
const errorMsg: string = ITextTranslation.translateText(
"ReaderErrorMessages/TupletNoteDurationError", "Invalid tuplet note duration."
Avoid deeply nested control flow statements. Open
if (this.tupletDict[tupletNumber]) {
delete this.tupletDict[tupletNumber];
if (Object.keys(this.tupletDict).length === 0) {
this.openTupletNumber = 0;
} else if (Object.keys(this.tupletDict).length > 1) {
Function checkOpenTies
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public checkOpenTies(): void {
const openTieDict: { [key: number]: Tie } = this.openTieDict;
for (const key in openTieDict) {
if (openTieDict.hasOwnProperty(key)) {
const tie: Tie = openTieDict[key];
- 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 getTupletNoteDurationFromType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private getTupletNoteDurationFromType(xmlNode: IXmlElement): Fraction {
if (xmlNode.element("type")) {
const typeNode: IXmlElement = xmlNode.element("type");
if (typeNode) {
const type: string = typeNode.value;
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!tuplet.PlacementFromXml) {
let foundNonRest: boolean = false;
for (const subList of tuplet.Notes) {
for (const note of subList) {
if (!note.isRest()) {
- Read upRead up
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 142.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!tuplet.PlacementFromXml) {
let foundNonRest: boolean = false;
for (const subList of tuplet.Notes) {
for (const note of subList) {
if (!note.isRest()) {
- Read upRead up
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 142.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (pitchElement.name === "octave") {
noteOctave = parseInt(pitchElement.value, 10);
if (isNaN(noteOctave)) {
const errorMsg: string = ITextTranslation.translateText(
"ReaderErrorMessages/NoteOctaveError", "Invalid octave value while reading note."
- Read upRead up
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 78.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (timeModNode) {
tupletLabelNumber = parseInt(timeModNode.value, 10);
if (isNaN(tupletLabelNumber)) {
const errorMsg: string = ITextTranslation.translateText(
"ReaderErrorMessages/TupletNoteDurationError", "Invalid tuplet note duration."
- Read upRead up
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 78.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
if (Object.keys(this.tupletDict).length === 0) {
this.openTupletNumber = 0;
} else if (Object.keys(this.tupletDict).length > 1) {
this.openTupletNumber--;
}
- Read upRead up
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 75.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
if (Object.keys(this.tupletDict).length === 0) {
this.openTupletNumber = 0;
} else if (Object.keys(this.tupletDict).length > 1) {
this.openTupletNumber--;
}
- Read upRead up
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 75.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 3 locations. Consider refactoring. Open
if (Object.keys(this.tupletDict).length === 0) {
this.openTupletNumber = 0;
} else if (Object.keys(this.tupletDict).length > 1) {
this.openTupletNumber--;
}
- Read upRead up
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 75.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (placementAttr) {
if (placementAttr.value === "below") {
tuplet.tupletLabelNumberPlacement = PlacementEnum.Below;
} else {
tuplet.tupletLabelNumberPlacement = PlacementEnum.Above;
- Read upRead up
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 67.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (placementAttr) {
if (placementAttr.value === "below") {
tuplet.tupletLabelNumberPlacement = PlacementEnum.Below;
} else {
tuplet.tupletLabelNumberPlacement = PlacementEnum.Above;
- Read upRead up
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 67.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (bracketAttr && bracketAttr.value === "yes") {
bracketed = true;
bracketedXmlValue = true;
} else if (bracketAttr && bracketAttr.value === "no") {
bracketedXmlValue = false;
- Read upRead up
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 60.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (bracketAttr && bracketAttr.value === "yes") {
bracketed = true;
bracketedXmlValue = true;
} else if (bracketAttr && bracketAttr.value === "no") {
bracketedXmlValue = false;
- Read upRead up
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 60.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (orientationAttr) {
if (orientationAttr.value === "over") {
tieDirection = PlacementEnum.Above;
} else if (orientationAttr.value === "under") {
tieDirection = PlacementEnum.Below;
- Read upRead up
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 60.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
const beamNode: IXmlElement = node.element("beam");
let beamAttr: IXmlAttribute = undefined;
if (beamNode !== undefined && beamNode.hasAttributes) {
beamAttr = beamNode.attribute("number");
- Read upRead up
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 55.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
return NoteTypeHandler.getNoteDurationFromType(type);
} catch (e) {
const errorMsg: string = ITextTranslation.translateText("ReaderErrorMessages/NoteDurationError", "Invalid note duration.");
this.musicSheet.SheetErrors.pushMeasureError(errorMsg);
- Read upRead up
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 55.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
if (type === "start") {
const num: number = this.findCurrentNoteInTieDict(this.currentNote);
if (num < 0) {
delete this.openTieDict[num];
- Read upRead up
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 47.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
} else if (accidentalValue === "sori") {
noteAccidental = AccidentalEnum.SORI;
} else if (accidentalValue === "koron") {
noteAccidental = AccidentalEnum.KORON;
}
- Read upRead up
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 45.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76