-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from db1group/feature/add-technical-debt-indicator
Feature/add technical debt indicator
- Loading branch information
Showing
37 changed files
with
336 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/domain/quality-provider.ts → src/application/quality-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { TechnicalDebt } from '@/domain/technical-debt/TechnicalDebt'; | ||
|
||
export interface TechnicalDebtProvider { | ||
getTechnicalDebtFromProject(project: string): Promise<TechnicalDebt>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { HealthScore, HealthScoreItem } from './HealthScore'; | ||
import { Project } from './Project'; | ||
import { NoProjectError } from './health-score/exceptions/InvalidProjectError'; | ||
|
||
export class Company { | ||
private readonly projects: Project[]; | ||
|
||
constructor(projects: Project[]) { | ||
this.projects = projects; | ||
if (this.projects.length === 0) { | ||
throw new NoProjectError(); | ||
} | ||
} | ||
|
||
public calculateHealthScore(): HealthScore { | ||
const items = this.calculateItems(); | ||
|
||
const acummulatedScore = items.reduce((acc, item) => { | ||
return acc + item.value | ||
}, 0); | ||
|
||
const healthScoreRounded = | ||
Math.round((acummulatedScore / this.projects.length) * 100) / 100; | ||
|
||
const acummulatedDebt = items.reduce((acc, item) => { | ||
return acc + item.technicalDebt; | ||
}, 0); | ||
|
||
return { | ||
value: healthScoreRounded, | ||
technicalDebt: acummulatedDebt, | ||
items, | ||
} | ||
} | ||
|
||
private calculateItems(): HealthScoreItem[] { | ||
return this.projects.map((project) => { | ||
const technicalDebt = project.calculateTechnicalDebt(); | ||
const value = project.calculateHealthScore(); | ||
return { | ||
project: project.name, | ||
technicalDebt, | ||
value, | ||
}; | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export class HealthScore { | ||
value: number; | ||
technicalDebt: number; | ||
items: HealthScoreItem[]; | ||
} | ||
|
||
export class HealthScoreItem { | ||
project: string; | ||
technicalDebt: number; | ||
value: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
import { QualityMeasures } from './measures/QualityMeasures'; | ||
import { QualityMeasures } from './health-score/measures/QualityMeasures'; | ||
import { TechnicalDebt } from './technical-debt/TechnicalDebt'; | ||
|
||
export class Project { | ||
constructor(private readonly qualityMeasures: QualityMeasures[]) {} | ||
constructor( | ||
public readonly name: string, | ||
private readonly qualityMeasures: QualityMeasures[], | ||
private readonly technicalDebt: TechnicalDebt, | ||
) { } | ||
|
||
calculateHealthScore(): number { | ||
return this.qualityMeasures.reduce((acc, qualityMeasure) => { | ||
return acc + qualityMeasure.getQualityRatio(); | ||
}, 0); | ||
} | ||
|
||
calculateTechnicalDebt(): number { | ||
return this.technicalDebt.calculateTechnicalDebt(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class TechnicalDebt { | ||
constructor(private readonly value: number) {} | ||
|
||
calculateTechnicalDebt(): number { | ||
const hour = 60; | ||
const technicalDebtInHours = this.value / hour; | ||
return technicalDebtInHours; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { TECHICAL_DEBT } from '../../domain/health-score/measures/QualityMeasures'; | ||
import { SonarMetricResponse } from './sonar-http-client'; | ||
|
||
import { TechnicalDebt } from '@/domain/technical-debt/TechnicalDebt'; | ||
|
||
export class SonarTechicalDebtAdapter { | ||
constructor(private readonly sonarResponse: SonarMetricResponse) {} | ||
execute(): TechnicalDebt { | ||
const sonarMeasures = this.sonarResponse.component.measures; | ||
|
||
const technicalDebtValue = sonarMeasures.find( | ||
(sonarMeasure) => sonarMeasure.metric === TECHICAL_DEBT, | ||
); | ||
|
||
return new TechnicalDebt(Number(technicalDebtValue.value)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.