File MusicSystemBuilder.ts
has 976 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {GraphicalMeasure} from "./GraphicalMeasure";
import {GraphicalMusicPage} from "./GraphicalMusicPage";
import {EngravingRules} from "./EngravingRules";
import {RhythmInstruction} from "../VoiceData/Instructions/RhythmInstruction";
import {KeyInstruction} from "../VoiceData/Instructions/KeyInstruction";
Function buildMusicSystems
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
public buildMusicSystems(): MusicSystem[] {
const systemMaxWidth: number = this.getFullPageSystemWidth();
let prevMeasureEndsPart: boolean = false;
this.measureListIndex = 0;
this.currentSystemParams = new SystemBuildParameters();
- 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
MusicSystemBuilder
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
export class MusicSystemBuilder {
protected measureList: GraphicalMeasure[][];
protected graphicalMusicSheet: GraphicalMusicSheet;
protected currentSystemParams: SystemBuildParameters;
protected numberOfVisibleStaffLines: number;
Function updateActiveClefs
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
protected updateActiveClefs(measure: SourceMeasure, graphicalMeasures: GraphicalMeasure[]): void {
for (let visStaffIdx: number = 0, len: number = graphicalMeasures.length; visStaffIdx < len; visStaffIdx++) {
const staffIndex: number = this.visibleStaffIndices[visStaffIdx];
const firstEntry: SourceStaffEntry = measure.FirstInstructionsStaffEntries[staffIndex];
if (firstEntry) {
- 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 AddInstructionsAtMeasureBegin
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
protected AddInstructionsAtMeasureBegin(firstEntry: SourceStaffEntry, measure: GraphicalMeasure,
visibleStaffIdx: number, isFirstSourceMeasure: boolean, isSystemStartMeasure: boolean): number {
let instructionsLengthX: number = 0;
let currentClef: ClefInstruction = undefined;
let currentKey: KeyInstruction = undefined;
- 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 stretchMusicSystem
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
protected stretchMusicSystem(systemEndsPart: boolean): void {
let scalingFactor: number = this.calculateXScalingFactor(
this.currentSystemParams.currentSystemFixWidth, this.currentSystemParams.currentSystemVarWidth
);
if (systemEndsPart) {
- 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 calculateMusicSystemsRelativePositions
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
protected calculateMusicSystemsRelativePositions(): void {
let currentPage: GraphicalMusicPage = this.createMusicPage();
let currentYPosition: number = 0;
// xPosition is always fixed
let currentSystem: MusicSystem = this.musicSystems[0];
- 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 buildMusicSystems
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
public buildMusicSystems(): MusicSystem[] {
const systemMaxWidth: number = this.getFullPageSystemWidth();
let prevMeasureEndsPart: boolean = false;
this.measureListIndex = 0;
this.currentSystemParams = new SystemBuildParameters();
Function layoutSystemStaves
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
protected layoutSystemStaves(musicSystem: MusicSystem): void {
const systemWidth: number = this.getFullPageSystemWidth();
const boundingBox: BoundingBox = musicSystem.PositionAndShape;
boundingBox.BorderLeft = 0.0;
boundingBox.BorderRight = systemWidth;
- 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 AddInstructionsAtMeasureBegin
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected AddInstructionsAtMeasureBegin(firstEntry: SourceStaffEntry, measure: GraphicalMeasure,
visibleStaffIdx: number, isFirstSourceMeasure: boolean, isSystemStartMeasure: boolean): number {
let instructionsLengthX: number = 0;
let currentClef: ClefInstruction = undefined;
let currentKey: KeyInstruction = undefined;
Function calculateMusicSystemsRelativePositions
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected calculateMusicSystemsRelativePositions(): void {
let currentPage: GraphicalMusicPage = this.createMusicPage();
let currentYPosition: number = 0;
// xPosition is always fixed
let currentSystem: MusicSystem = this.musicSystems[0];
Function checkAndCreateExtraInstructionMeasure
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
protected checkAndCreateExtraInstructionMeasure(measures: GraphicalMeasure[]): void {
const firstStaffEntries: SourceStaffEntry[] = measures[0].parentSourceMeasure.FirstInstructionsStaffEntries;
const visibleInstructionEntries: SourceStaffEntry[] = [];
for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
const measure: GraphicalMeasure = measures[idx];
- 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 stretchMusicSystem
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected stretchMusicSystem(systemEndsPart: boolean): void {
let scalingFactor: number = this.calculateXScalingFactor(
this.currentSystemParams.currentSystemFixWidth, this.currentSystemParams.currentSystemVarWidth
);
if (systemEndsPart) {
Function layoutSystemStaves
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected layoutSystemStaves(musicSystem: MusicSystem): void {
const systemWidth: number = this.getFullPageSystemWidth();
const boundingBox: BoundingBox = musicSystem.PositionAndShape;
boundingBox.BorderLeft = 0.0;
boundingBox.BorderRight = systemWidth;
Function updateActiveClefs
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected updateActiveClefs(measure: SourceMeasure, graphicalMeasures: GraphicalMeasure[]): void {
for (let visStaffIdx: number = 0, len: number = graphicalMeasures.length; visStaffIdx < len; visStaffIdx++) {
const staffIndex: number = this.visibleStaffIndices[visStaffIdx];
const firstEntry: SourceStaffEntry = measure.FirstInstructionsStaffEntries[staffIndex];
if (firstEntry) {
Function checkAndCreateExtraInstructionMeasure
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected checkAndCreateExtraInstructionMeasure(measures: GraphicalMeasure[]): void {
const firstStaffEntries: SourceStaffEntry[] = measures[0].parentSourceMeasure.FirstInstructionsStaffEntries;
const visibleInstructionEntries: SourceStaffEntry[] = [];
for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
const measure: GraphicalMeasure = measures[idx];
Function thisMeasureEndsLineRepetition
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected thisMeasureEndsLineRepetition(): boolean {
for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
const measure: GraphicalMeasure = this.measureList[this.measureListIndex][idx];
if (measure.endsWithLineRepetition()) {
return true;
- 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 addInstructionsAtMeasureEnd
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected addInstructionsAtMeasureEnd(lastEntry: SourceStaffEntry, measure: GraphicalMeasure,
measures: GraphicalMeasure[]): number {
if (!lastEntry || !lastEntry.Instructions || lastEntry.Instructions.length === 0) {
return 0;
}
- 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 findRequiredDistanceWithSkyBottomLine
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private findRequiredDistanceWithSkyBottomLine(upperSystem: MusicSystem, lowerSystem: MusicSystem): number {
const upperSystemLastStaffLine: StaffLine = upperSystem.StaffLines[upperSystem.StaffLines.length - 1];
const lowerSystemFirstStaffLine: StaffLine = lowerSystem.StaffLines[0];
const upperBottomLineArray: number[] = upperSystemLastStaffLine.BottomLine;
const lowerSkyLineArray: number[] = lowerSystemFirstStaffLine.SkyLine;
Function getMeasureEndLine
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected getMeasureEndLine(): SystemLinesEnum {
let sourceMeasure: SourceMeasure = undefined;
try {
sourceMeasure = this.measureList[this.measureListIndex][0].parentSourceMeasure;
if (this.rules.RenderMultipleRestMeasures && sourceMeasure.multipleRestMeasures > 1) {
Function optimizeDistanceBetweenStaffLines
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected optimizeDistanceBetweenStaffLines(musicSystem: MusicSystem): void {
// don't perform any y-spacing in case of a StaffEntryLink (in both StaffLines)
if (!musicSystem.checkStaffEntriesForStaffEntryLink()) {
for (let i: number = 0; i < musicSystem.StaffLines.length - 1; i++) {
const upperBottomLine: number[] = musicSystem.StaffLines[i].BottomLine;
- 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 optimizeDistanceBetweenStaffLines
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected optimizeDistanceBetweenStaffLines(musicSystem: MusicSystem): void {
// don't perform any y-spacing in case of a StaffEntryLink (in both StaffLines)
if (!musicSystem.checkStaffEntriesForStaffEntryLink()) {
for (let i: number = 0; i < musicSystem.StaffLines.length - 1; i++) {
const upperBottomLine: number[] = musicSystem.StaffLines[i].BottomLine;
Avoid deeply nested control flow statements. Open
if (measureIndex === 0) {
xPosition = currentXPosition + measure.beginInstructionsWidth - lineWidth;
}
Avoid deeply nested control flow statements. Open
if (abstractNotationInstruction instanceof ClefInstruction) {
this.activeClefs[visStaffIdx] = <ClefInstruction>abstractNotationInstruction;
}
Function findRequiredDistanceWithSkyBottomLine
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private findRequiredDistanceWithSkyBottomLine(upperSystem: MusicSystem, lowerSystem: MusicSystem): number {
const upperSystemLastStaffLine: StaffLine = upperSystem.StaffLines[upperSystem.StaffLines.length - 1];
const lowerSystemFirstStaffLine: StaffLine = lowerSystem.StaffLines[0];
const upperBottomLineArray: number[] = upperSystemLastStaffLine.BottomLine;
const lowerSkyLineArray: number[] = lowerSystemFirstStaffLine.SkyLine;
- 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 getMeasureEndLine
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected getMeasureEndLine(): SystemLinesEnum {
let sourceMeasure: SourceMeasure = undefined;
try {
sourceMeasure = this.measureList[this.measureListIndex][0].parentSourceMeasure;
if (this.rules.RenderMultipleRestMeasures && sourceMeasure.multipleRestMeasures > 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
Function getMeasureStartLine
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected getMeasureStartLine(): SystemLinesEnum {
const thisMeasureBeginsLineRep: boolean = this.thisMeasureBeginsLineRepetition();
if (thisMeasureBeginsLineRep) {
const isGlobalFirstMeasure: boolean = this.measureListIndex === 0;
if (isGlobalFirstMeasure && this.rules.RepetitionAllowFirstMeasureBeginningRepeatBarline) {
- 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 too many return
statements within this function. Open
return sourceMeasure.endingBarStyleEnum;
Avoid too many return
statements within this function. Open
return SystemLinesEnum.SingleThin;
Function getNextMeasureKeyInstruction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected getNextMeasureKeyInstruction(): KeyInstruction {
if (this.measureListIndex < this.measureList.length - 1) {
for (let visIndex: number = 0; visIndex < this.measureList[this.measureListIndex].length; visIndex++) {
const sourceMeasure: SourceMeasure = this.measureList[this.measureListIndex + 1][visIndex]?.parentSourceMeasure;
if (!sourceMeasure) {
- 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 addStaffLineToMusicSystem
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected addStaffLineToMusicSystem(musicSystem: MusicSystem, relativeYPosition: number, staff: Staff): void {
if (musicSystem) {
const staffLine: StaffLine = MusicSheetCalculator.symbolFactory.createStaffLine(musicSystem, staff);
musicSystem.StaffLines.push(staffLine);
const boundingBox: BoundingBox = staffLine.PositionAndShape;
- 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 initializeActiveInstructions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected initializeActiveInstructions(measureList: GraphicalMeasure[]): void {
const firstSourceMeasure: SourceMeasure = this.graphicalMusicSheet.ParentMusicSheet.getFirstSourceMeasure();
if (firstSourceMeasure) {
this.visibleStaffIndices = this.graphicalMusicSheet.getVisibleStavesIndicesFromSourceMeasure(measureList);
for (let i: number = 0, len: number = this.visibleStaffIndices.length; i < len; i++) {
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected thisMeasureBeginsLineRepetition(): boolean {
for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
const measure: GraphicalMeasure = this.measureList[this.measureListIndex][idx];
if (measure.beginsWithLineRepetition()) {
return true;
- 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 117.
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
protected thisMeasureEndsWordRepetition(): boolean {
for (let idx: number = 0, len: number = this.measureList[this.measureListIndex].length; idx < len; ++idx) {
const measure: GraphicalMeasure = this.measureList[this.measureListIndex][idx];
if (measure.endsWithWordRepetition()) {
return true;
- 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 117.
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
for (let idx: number = 0, len: number = this.measureList[nextMeasureIndex].length; idx < len; ++idx) {
const measure: GraphicalMeasure = this.measureList[nextMeasureIndex][idx];
if (measure.beginsWithLineRepetition()) {
return true;
}
- 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 90.
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
for (let idx: number = 0, len: number = this.measureList[nextMeasureIndex].length; idx < len; ++idx) {
const measure: GraphicalMeasure = this.measureList[nextMeasureIndex][idx];
if (measure.beginsWithWordRepetition()) {
return true;
}
- 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 90.
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
for (let idx: number = 0, len: number = measures.length; idx < len; ++idx) {
const measure: GraphicalMeasure = measures[idx];
measure.endInstructionsWidth -= diff;
}
- 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 68.
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
for (let lowerIdx: number = startIdx; lowerIdx <= endIdx; lowerIdx++) {
skylineValue = Math.min(skylineValue, lowerSkyLineArray[lowerIdx]);
}
- 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 2 locations. Consider refactoring. Open
for (let lowerIdx: number = startIdx; lowerIdx <= endIdx; lowerIdx++) {
skylineValue = Math.min(skylineValue, lowerSkyLine[lowerIdx]);
}
- 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 2 locations. Consider refactoring. Open
for (let i: number = 0; i < graphicalMeasures.length; i++) {
gmeasures.push(graphicalMeasures[i]);
}
- 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 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
- 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