File h3-data.repository.ts
has 679 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
Brackets,
DataSource,
ObjectLiteral,
Repository,
Function baseGetImpactMap
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async baseGetImpactMap(
baseImpactMap: BaseImpactMap,
): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
let baseMapQuery: SelectQueryBuilder<any> = this.baseMapQuery(
baseImpactMap.indicatorId,
H3DataRepository
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
@Injectable()
export class H3DataRepository extends Repository<H3Data> {
constructor(private dataSource: DataSource) {
super(H3Data, dataSource.createEntityManager());
}
Function baseGetImpactMap
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private async baseGetImpactMap(
baseImpactMap: BaseImpactMap,
): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
let baseMapQuery: SelectQueryBuilder<any> = this.baseMapQuery(
baseImpactMap.indicatorId,
- 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 getActualVsScenarioImpactMap
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getActualVsScenarioImpactMap(
dto: GetActualVsScenarioImpactMapDto,
): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
//Add selection criteria to also select both comparedScenario in the select statement
Function getImpactMap
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getImpactMap(
dto: GetImpactMapDto,
): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
//Having a scenarioId present as an argument, will change the query to include
Function getScenarioVsScenarioImpactMap
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getScenarioVsScenarioImpactMap(
dto: GetScenarioVsScenarioImpactMapDto,
): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
//Add selection criteria to also select both baseScenario and comparedScenario in the select statement
Function addOrganisationalEntityFilters
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addOrganisationalEntityFilters(
baseImpactMapFilters: BaseImpactMapFiltersType,
queryBuilder: { subQueryBuilder: SelectQueryBuilder<any> },
): SelectQueryBuilder<any> {
const {
Function getAggregatedValuedByH3IndexAndResolution
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private getAggregatedValuedByH3IndexAndResolution(
baseMapQuery: SelectQueryBuilder<any>,
resolution: number,
mapType: IMPACT_MAP_TYPE,
): SelectQueryBuilder<any> {
Function calculateScenarioComparisonQuantiles
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async calculateScenarioComparisonQuantiles(
tmpTableName: string,
): Promise<number[]> {
try {
// due to the inner workings of the pg driver and the way it parses different number types
Function getMaterialMapByResolution
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getMaterialMapByResolution(
materialH3Data: H3Data,
resolution: number,
): Promise<{ materialMap: H3IndexValueData[]; quantiles: number[] }> {
const tmpTableName: string = H3DataRepository.generateRandomTableName();
Function getAvailableYearsForContextualLayer
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getAvailableYearsForContextualLayer(yearsRequestParams: {
layerType: LAYER_TYPES;
h3DataIds?: string[] | null;
indicatorId?: string;
}): Promise<number[]> {
Function getYears
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getYears(yearsRequestParams: {
layerType: LAYER_TYPES;
h3DataIds?: string[] | null;
indicatorId?: string;
}): Promise<number[]> {
Function baseQueryExtend
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
//Add selection criteria to also select both comparedScenario in the select statement
baseQuery
.leftJoin(
ScenarioIntervention,
Function baseQueryExtend
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
//Having a scenarioId present as an argument, will change the query to include
// *all* indicator records of the interventions pertaining to that scenario (both
// the CANCELLED and REPLACING records)
if (dto.scenarioId) {
Function addOrganisationalEntityFilters
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private addOrganisationalEntityFilters(
baseImpactMapFilters: BaseImpactMapFiltersType,
queryBuilder: { subQueryBuilder: SelectQueryBuilder<any> },
): SelectQueryBuilder<any> {
const {
- 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
async getAvailableYearsForContextualLayer(yearsRequestParams: {
layerType: LAYER_TYPES;
h3DataIds?: string[] | null;
indicatorId?: string;
}): Promise<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 267.
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
async getYears(yearsRequestParams: {
layerType: LAYER_TYPES;
h3DataIds?: string[] | null;
indicatorId?: string;
}): Promise<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 267.
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 (dto.scenarioId) {
baseQuery
.leftJoin(
ScenarioIntervention,
'si',
- 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 122.
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
return this.baseGetImpactMap({
indicatorId: dto.indicatorId,
resolution: dto.resolution,
year: dto.year,
mapType: IMPACT_MAP_TYPE.SCENARIO_VS_SCENARIO,
- 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 121.
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
return this.baseGetImpactMap({
indicatorId: dto.indicatorId,
resolution: dto.resolution,
year: dto.year,
mapType: IMPACT_MAP_TYPE.ACTUAL_VS_SCENARIO,
- 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 121.
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
const queryBuilder: SelectQueryBuilder<H3Data> = this.dataSource
.createQueryBuilder()
.select(' h3data.*')
.from(H3Data, 'h3data')
.leftJoin('indicator', 'indicator', 'h3data.indicatorId = indicator.id')
- 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 59.
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
const queryBuilder: SelectQueryBuilder<H3Data> = this.dataSource
.createQueryBuilder()
.select('h3data.*')
.from(H3Data, 'h3data')
.leftJoin(
- 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 59.
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 (baseImpactMap.mapType === IMPACT_MAP_TYPE.SCENARIO_VS_SCENARIO) {
if (baseImpactMap.isRelative) {
finalQueryBuiler.select(
'100 * (ABS(q.aggregated_compared) - ABS(q.aggregated_base)) / NULLIF(((ABS(q.aggregated_compared) + ABS(q.aggregated_base)) / 2), 0)',
'v',
- 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 58.
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 (baseImpactMap.mapType === IMPACT_MAP_TYPE.ACTUAL_VS_SCENARIO) {
if (baseImpactMap.isRelative) {
finalQueryBuiler.select(
'100 * (ABS(q.aggregated_scenario_data) - ABS(q.aggregated_actual_data)) / NULLIF(((ABS(q.aggregated_scenario_data) + ABS(q.aggregated_actual_data)) / 2), 0)',
'v',
- 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 58.
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
{
materialIds: baseImpactMap.materialIds,
originIds: baseImpactMap.originIds,
t1SupplierIds: baseImpactMap.t1SupplierIds,
producerIds: baseImpactMap.producerIds,
- 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 56.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- 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
const years: { year: number }[] = await this.createQueryBuilder('h3data')
.select('year')
.leftJoin('material_to_h3', 'mth', 'h3data.id = mth.h3DataId')
.where('mth.materialId = :materialId', { materialId })
.andWhere('mth.type = :materialType', { materialType })
- 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
const years: { year: number }[] = await this.createQueryBuilder('h3data')
.select('year')
.leftJoin('indicator', 'i', 'h3data.indicatorId = i.id')
.where('h3data.indicatorId = :indicatorId', { indicatorId })
.orderBy('year', 'DESC')
- 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