File GraphicalMusicSheet.ts
has 863 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {MusicSheet} from "../MusicSheet";
import {SourceMeasure} from "../VoiceData/SourceMeasure";
import {GraphicalMeasure} from "./GraphicalMeasure";
import {GraphicalMusicPage} from "./GraphicalMusicPage";
import {VerticalGraphicalStaffEntryContainer} from "./VerticalGraphicalStaffEntryContainer";
GraphicalMusicSheet
has 74 functions (exceeds 20 allowed). Consider refactoring. Open
export class GraphicalMusicSheet {
constructor(musicSheet: MusicSheet, calculator: MusicSheetCalculator) {
this.musicSheet = musicSheet;
this.numberOfStaves = this.musicSheet.Staves.length;
this.calculator = calculator;
Function GetNearestGraphicalObject
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private GetNearestGraphicalObject<T extends GraphicalObject>(
clickPosition: PointF2D, className: string = GraphicalObject.name,
startSearchArea: number = 5, maxSearchArea: number = 20, searchAreaIncrement: number = 5,
shouldBeIncludedTest: (objectToTest: T) => boolean = undefined): T {
const foundEntries: T[] = [];
- 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 calculateXPositionFromTimestamp
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public calculateXPositionFromTimestamp(timeStamp: Fraction): [number, MusicSystem] {
let currentMusicSystem: MusicSystem = undefined;
const fractionalIndex: number = this.GetInterpolatedIndexInVerticalContainers(timeStamp);
const previousStaffEntry: GraphicalStaffEntry = this.findClosestLeftStaffEntry(fractionalIndex, true);
const nextStaffEntry: GraphicalStaffEntry = this.findClosestRightStaffEntry(fractionalIndex, true);
Function calculateXPositionFromTimestamp
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public calculateXPositionFromTimestamp(timeStamp: Fraction): [number, MusicSystem] {
let currentMusicSystem: MusicSystem = undefined;
const fractionalIndex: number = this.GetInterpolatedIndexInVerticalContainers(timeStamp);
const previousStaffEntry: GraphicalStaffEntry = this.findClosestLeftStaffEntry(fractionalIndex, true);
const nextStaffEntry: GraphicalStaffEntry = this.findClosestRightStaffEntry(fractionalIndex, 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 GetNearestStaffEntry
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public GetNearestStaffEntry(clickPosition: PointF2D): GraphicalStaffEntry {
const initialSearchArea: number = 10;
const foundEntries: GraphicalStaffEntry[] = [];
// Prepare search area
const region: BoundingBox = new BoundingBox(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 initializeActiveClefs
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public initializeActiveClefs(): ClefInstruction[] {
const activeClefs: ClefInstruction[] = [];
const firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
if (firstSourceMeasure) {
for (let i: number = 0; i < firstSourceMeasure.CompleteNumberOfStaves; 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
Function GetNearestObject
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public GetNearestObject<T extends GraphicalObject>(clickPosition: PointF2D, className: string): T {
const initialSearchArea: number = 10;
const foundEntries: T[] = [];
// Prepare search area
const region: BoundingBox = new BoundingBox(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 GetInterpolatedIndexInVerticalContainers
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public GetInterpolatedIndexInVerticalContainers(musicTimestamp: Fraction): number {
const containers: VerticalGraphicalStaffEntryContainer[] = this.verticalGraphicalStaffEntryContainers;
if (containers.length === 1) {
return 0; // this fixes an error with Noteflight samples, see below (#1473). It may also be faster.
}
- 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 GetNearestGraphicalObject
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private GetNearestGraphicalObject<T extends GraphicalObject>(
clickPosition: PointF2D, className: string = GraphicalObject.name,
startSearchArea: number = 5, maxSearchArea: number = 20, searchAreaIncrement: number = 5,
shouldBeIncludedTest: (objectToTest: T) => boolean = undefined): T {
const foundEntries: T[] = [];
Function GetNearestStaffEntry
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public GetNearestStaffEntry(clickPosition: PointF2D): GraphicalStaffEntry {
const initialSearchArea: number = 10;
const foundEntries: GraphicalStaffEntry[] = [];
// Prepare search area
const region: BoundingBox = new BoundingBox(undefined);
Function GetInterpolatedIndexInVerticalContainers
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public GetInterpolatedIndexInVerticalContainers(musicTimestamp: Fraction): number {
const containers: VerticalGraphicalStaffEntryContainer[] = this.verticalGraphicalStaffEntryContainers;
if (containers.length === 1) {
return 0; // this fixes an error with Noteflight samples, see below (#1473). It may also be faster.
}
Function GetNearestObject
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public GetNearestObject<T extends GraphicalObject>(clickPosition: PointF2D, className: string): T {
const initialSearchArea: number = 10;
const foundEntries: T[] = [];
// Prepare search area
const region: BoundingBox = new BoundingBox(undefined);
Function orderMeasuresByStaffLine
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public orderMeasuresByStaffLine(measures: GraphicalMeasure[]): GraphicalMeasure[][] {
const orderedMeasures: GraphicalMeasure[][] = [];
let mList: GraphicalMeasure[] = [];
orderedMeasures.push(mList);
for (let i: number = 0; i < measures.length; 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
Function findClosestLeftStaffEntry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public findClosestLeftStaffEntry(fractionalIndex: number, searchOnlyVisibleEntries: boolean): GraphicalStaffEntry {
let foundEntry: GraphicalStaffEntry = undefined;
let leftIndex: number = Math.floor(fractionalIndex);
leftIndex = Math.min(this.VerticalGraphicalStaffEntryContainers.length - 1, leftIndex);
for (let i: number = leftIndex; i >= 0; 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
Function getStaffEntry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public getStaffEntry(index: number): GraphicalStaffEntry {
const container: VerticalGraphicalStaffEntryContainer = this.VerticalGraphicalStaffEntryContainers[index];
let staffEntry: GraphicalStaffEntry = undefined;
try {
for (let idx: number = 0, len: number = container.StaffEntries.length; idx < len; ++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 findClosestRightStaffEntry
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public findClosestRightStaffEntry(fractionalIndex: number, returnOnlyVisibleEntries: boolean): GraphicalStaffEntry {
let foundEntry: GraphicalStaffEntry = undefined;
const rightIndex: number = Math.max(0, Math.ceil(fractionalIndex));
for (let i: number = rightIndex; i < this.VerticalGraphicalStaffEntryContainers.length; i++) {
foundEntry = this.getStaffEntry(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
Function GetMainKey
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public GetMainKey(): KeyInstruction {
const firstSourceMeasure: SourceMeasure = this.musicSheet.getFirstSourceMeasure();
if (firstSourceMeasure) {
for (let i: number = 0; i < firstSourceMeasure.CompleteNumberOfStaves; i++) {
for (let idx: number = 0, len: number = firstSourceMeasure.FirstInstructionsStaffEntries[i].Instructions.length; idx < len; ++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 findGraphicalStaffEntryFromMeasureList
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public findGraphicalStaffEntryFromMeasureList(staffIndex: number, measureIndex: number, sourceStaffEntry: SourceStaffEntry): GraphicalStaffEntry {
for (let i: number = measureIndex; i < this.measureList.length; i++) {
const graphicalMeasure: GraphicalMeasure = this.measureList[i][staffIndex];
if (!graphicalMeasure) {
continue;
- 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 (abstractNotationInstruction instanceof ClefInstruction) {
clef = <ClefInstruction>abstractNotationInstruction;
}
Avoid deeply nested control flow statements. Open
if (!shouldBeIncludedTest) {
foundEntries.push(entries[idx2]);
} else if (shouldBeIncludedTest(entries[idx2])) {
foundEntries.push(entries[idx2]);
}
Function GetClickableLabel
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public GetClickableLabel(clickPosition: PointF2D): GraphicalLabel {
const initialSearchAreaX: number = 4;
const initialSearchAreaY: number = 4;
// Prepare search area
const region: BoundingBox = new BoundingBox();
- 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 getOrCreateVerticalContainer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public getOrCreateVerticalContainer(timestamp: Fraction): VerticalGraphicalStaffEntryContainer {
if (this.verticalGraphicalStaffEntryContainers.length === 0 ||
(CollectionUtil.getLastElement(this.verticalGraphicalStaffEntryContainers).AbsoluteTimestamp).lt(timestamp)) {
const verticalGraphicalStaffEntryContainer: VerticalGraphicalStaffEntryContainer =
new VerticalGraphicalStaffEntryContainer(this.numberOfStaves, timestamp);
- 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 getFirstVisibleMeasuresListFromIndices
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public getFirstVisibleMeasuresListFromIndices(start: number, end: number): GraphicalMeasure[] {
const graphicalMeasures: GraphicalMeasure[] = [];
const numberOfStaves: number = this.measureList[0].length;
for (let i: number = start; i <= end; i++) {
for (let j: number = 0; j < numberOfStaves; j++) {
- 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 findGraphicalMeasureByMeasureNumber
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public findGraphicalMeasureByMeasureNumber(measureNumber: number, staffIndex: number): GraphicalMeasure {
// start with index = measureNumber, as a piece with a pickup measure starts with measure number 0
for (let i: number = measureNumber; i >= 0; i--) {
if (this.MeasureList[i]) {
const measure: GraphicalMeasure = this.MeasureList[i][staffIndex];
- 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 getMeasureIndex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public getMeasureIndex(graphicalMeasure: GraphicalMeasure, measureIndex: number, inListIndex: number): boolean {
measureIndex = 0;
inListIndex = 0;
for (; measureIndex < this.measureList.length; measureIndex++) {
for (let idx: number = 0, len: number = this.measureList[measureIndex].length; idx < len; ++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 GetPreviousVisibleContainerIndex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public GetPreviousVisibleContainerIndex(index: number): number {
for (let i: number = index - 1; i >= 0; i--) {
const entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
const entry: GraphicalStaffEntry = entries[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 GetNextVisibleContainerIndex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public GetNextVisibleContainerIndex(index: number): number {
for (let i: number = index + 1; i < this.verticalGraphicalStaffEntryContainers.length; ++i) {
const entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
const entry: GraphicalStaffEntry = entries[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 getVisibleStavesIndicesFromSourceMeasure
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public getVisibleStavesIndicesFromSourceMeasure(visibleMeasures: GraphicalMeasure[]): number[] {
const visibleInstruments: Instrument[] = [];
const visibleStavesIndices: number[] = [];
for (let idx: number = 0, len: number = visibleMeasures.length; idx < len; ++idx) {
const graphicalMeasure: GraphicalMeasure = visibleMeasures[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
Identical blocks of code found in 2 locations. Consider refactoring. Open
for (let i: number = index - 1; i >= 0; i--) {
const entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
const entry: GraphicalStaffEntry = entries[idx];
if (entry && entry.sourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
- 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 118.
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
for (let i: number = index + 1; i < this.verticalGraphicalStaffEntryContainers.length; ++i) {
const entries: GraphicalStaffEntry[] = this.verticalGraphicalStaffEntryContainers[i].StaffEntries;
for (let idx: number = 0, len: number = entries.length; idx < len; ++idx) {
const entry: GraphicalStaffEntry = entries[idx];
if (entry && entry.sourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
- 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 118.
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
public GetNumberOfFollowedInstruments(): number {
let followedInstrumentCount: number = 0;
for (let idx: number = 0, len: number = this.musicSheet.Instruments.length; idx < len; ++idx) {
const instrument: Instrument = this.musicSheet.Instruments[idx];
if (instrument.Following === 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 111.
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
public GetNumberOfVisibleInstruments(): number {
let visibleInstrumentCount: number = 0;
for (let idx: number = 0, len: number = this.musicSheet.Instruments.length; idx < len; ++idx) {
const instrument: Instrument = this.musicSheet.Instruments[idx];
if (instrument.Visible === 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 111.
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 (!entries || entries.length === 0) {
continue;
} else {
for (let idx2: number = 0, len2: number = entries.length; idx2 < len2; ++idx2) {
const gse: GraphicalStaffEntry = entries[idx2];
- 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 72.
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 (!entries || entries.length === 0) {
continue;
} else {
for (let idx2: number = 0, len2: number = entries.length; idx2 < len2; ++idx2) {
const entry: T = entries[idx2];
- 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 72.
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 = leftIndex; i >= 0; i--) {
foundEntry = this.getStaffEntry(i);
if (foundEntry) {
if (searchOnlyVisibleEntries) {
if (foundEntry.sourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
- 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 66.
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 = rightIndex; i < this.VerticalGraphicalStaffEntryContainers.length; i++) {
foundEntry = this.getStaffEntry(i);
if (foundEntry) {
if (returnOnlyVisibleEntries) {
if (foundEntry.sourceStaffEntry.ParentStaff.ParentInstrument.Visible) {
- 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 66.
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