Table of Contents

Interface IDebtFormatter

Namespace
NDepend.TechnicalDebt
Assembly
NDepend.API.dll

A IDebtFormatter object is used to format a TimeSpan value to human-readable object, like man-months string or money amount.

public interface IDebtFormatter
Extension Methods

Remarks

A IDebtFormatter object can be created from the IProject extension method ExtensionMethodsDebt.CreateDebtFormatter(DebtSettings).
A IDebtFormatter object is immutable. The settings it contains on which formatting is based, cannot be changed.

Property (1)

DebtSettings

Gets a cloned copy of the DebtSettings object from which formatting is done by this IDebtFormatter.

DebtSettings DebtSettings { get; }

Property Value

DebtSettings

Remarks

A IDebtFormatter object is immutable. The settings it contains on which formatting is based, cannot be changed. This is why this property returns a cloned copy of debts-settings.

Methods (45)

AnnualInterestThreshold(Severity)

Get the AnnualInterest threshold corresponding to the severity

AnnualInterest AnnualInterestThreshold(Severity severity)

Parameters

severity Severity

The severity level to get the threshold from.

Returns

AnnualInterest

Remarks

CostToReachBetterRating(Debt, ICodeElement)

Returns the estimated cost, to reach a better rating, based on the fact that codeElement has actually a total debt estimated to debt.

Debt? CostToReachBetterRating(Debt debt, ICodeElement codeElement)

Parameters

debt Debt

The estimated debt to fix all issues on codeElement

codeElement ICodeElement

The code element on which we infer the rating from the debt

Returns

Debt?

Remarks

Better rating means the rating just better than the actual one.
If code element actual rating is D, better rating is C.
If code element actual rating is B, better rating is A.
If code element actual rating is A, this method returns Debt.Zero.
If ToDebtRatio(Debt, ICodeElement) returns null for codeElement, this method returns null.

CostToReachRating(Debt, ICodeElement, DebtRating)

Returns the estimated effort to reach ratingToReach, based on the fact that codeElement has actually a total debt estimated to debt.

Debt? CostToReachRating(Debt debt, ICodeElement codeElement, DebtRating ratingToReach)

Parameters

debt Debt

The estimated debt to fix all issues on codeElement

codeElement ICodeElement

The code element on which we infer the rating from the debt

ratingToReach DebtRating

The rating to reach for codeElement

Returns

Debt?

Remarks

If the actual rating of codeElement given debt is equals or better than ratingToReach, this method returns a zero duration Debt value.
If ToDebtRatio(Debt, ICodeElement) returns null for codeElement, this method returns null.

EffortToDevelop(ICodeElement)

Evaluate the total time to develop codeElement based on codeElement.GetNbLinesOfCode_GuaranteedIfPDBFound(ICodeElement), by applying a linear coefficent inferred from this.DebtSettings.EstimatedNumberOfManDayToDevelop1000LogicalLinesOfCode and this.DebtSettings.NumberOfWorkHourPerDay.

TimeSpan? EffortToDevelop(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The code element on which to infer time-to-develop.

Returns

TimeSpan?

Remarks

This method returns null if codeElement.GetNbLinesOfCode_GuaranteedIfPDBFound(ICodeElement) returns null.

ToDebtRating(Debt, ICodeElement)

Estimate the debt rating of codeElement in the range A (very good) to E (very bad).

DebtRating? ToDebtRating(Debt debt, ICodeElement codeElement)

Parameters

debt Debt

The estimated debt to fix all issues on codeElement

codeElement ICodeElement

The code element on which we infer the rating from the debt

Returns

DebtRating?

The debt rating in the range A (very good) to E (very bad) or null if the method GetNbLinesOfCode_GuaranteedIfPDBFound(ICodeElement) returns null for codeElement.

Remarks

The debt rating is estimated by the value of the Technical Debt Ratio for codeElement obtained from ToDebtRatio(Debt, ICodeElement), and from the various rating thresholds defined in this this.DebtSettings object.
If ToDebtRatio(Debt, ICodeElement) returns null for codeElement, this method returns null as well.

ToDebtRatio(Debt, ICodeElement)

Estimate the ratio of technical debt, measured through debt, for codeElement. This ratio is expressed in percentage, of estimated debt, compared to the estimated time it would take to rewrite codeElement from scratch.

double? ToDebtRatio(Debt debt, ICodeElement codeElement)

Parameters

debt Debt

The estimated debt to fix all issues on codeElement

codeElement ICodeElement

The code element on which we infer the percentage of debt

Returns

double?

The percentage of technical debt or null if the metric NbLinesOfCode is not available for codeElement.

Remarks

This method is obtaining the number of lines of code for codeElement from the method, ExtensionMethodsHelpers.GetNbLinesOfCode_GuaranteedIfPDBFound(ICodeElement).
This method returns null, if and only if, GetNbLinesOfCode_GuaranteedIfPDBFound(ICodeElement) returns null for codeElement.
To estimate the time it would take to rewrite codeElement from scratch, both DebtSettings values are used:

ToDebtRatioString(Debt, ICodeElement)

Gets a string that represents the ratio of technical debt, measured through debt, for codeElement. This ratio is expressed in percentage of estimated debt to fix the debt, compared to the estimated duration it would take to rewrite codeElement from scratch.

string ToDebtRatioString(Debt debt, ICodeElement codeElement)

Parameters

debt Debt

The estimated debt to fix all issues on codeElement

codeElement ICodeElement

The code element on which we infer the percentage of debt

Returns

string

The percentage of technical debt or the string "N/A" if the metric NbLinesOfCode is not available for codeElement.

Remarks

This method is obtaining the number of lines of code for codeElement from the method, ExtensionMethodsHelpers.GetNbLinesOfCode_GuaranteedIfPDBFound(ICodeElement).
This method returns null, if and only if, GetNbLinesOfCode_GuaranteedIfPDBFound(ICodeElement) returns null for codeElement.
To estimate the time it would take to rewrite codeElement from scratch, both DebtSettings values are used:

ToManDay(AnnualInterest)

Gets a double number of man-days that represents annualInterest. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

double ToManDay(AnnualInterest annualInterest)

Parameters

annualInterest AnnualInterest

The estimated cost per year to leave one or several issues unfixed

Returns

double

ToManDay(Debt)

Gets a double number of man-days that represents debt. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

double ToManDay(Debt debt)

Parameters

debt Debt

The estimated effort to fix one or several issues

Returns

double

ToManDay(AnnualInterest?)

Gets a double number of man-days that represents annualInterest. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

double? ToManDay(AnnualInterest? annualInterest)

Parameters

annualInterest AnnualInterest?

The estimated nullable cost per year to leave one or several issues unfixed

Returns

double?

Remarks

If annualInterest is null this method returns null.

ToManDay(Debt?)

Gets a double number of man-days that represents debt. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

double? ToManDay(Debt? debt)

Parameters

debt Debt?

The estimated nullable cost to fix one or several issues

Returns

double?

Remarks

If debt is null this method returns null.

ToManDay(TimeSpan?)

Gets a double number of man-days that represents duration. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

double? ToManDay(TimeSpan? duration)

Parameters

duration TimeSpan?

The estimated nullable duration to fix one or several issues

Returns

double?

Remarks

If duration is null this method returns null.

ToManDay(TimeSpan)

Gets a double number of man-days that represents duration. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

double ToManDay(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

double

ToManDay(TimeSpan, out TimeSpan)

Gets an integer number of man-days that represents duration. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

int ToManDay(TimeSpan duration, out TimeSpan residualHoursMinutesSeconds)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

residualHoursMinutesSeconds TimeSpan

Out parameter that represents the residual less-than-a-man-day duration, expressed in hours/minutes/seconds

Returns

int

ToManDayString(TimeSpan)

Gets a string that represents duration as a number of man-days. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

string ToManDayString(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

string

Remarks

For example this method can return:
"1 234d 2h"

"2:02:43" if duration is less than a man-day
"2min 43s" if duration is less than an hour
If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

ToManDayStringDetailled(TimeSpan)

Gets a detailed string that represents duration as a number of man-days. The number of man-days is computed from this.DebtSettings.NumberOfWorkHourPerDay.

string ToManDayStringDetailled(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

string

Remarks

For example this method can return:
"1 234d 2:02:43"

"2:02:43" if duration is less than a man-days
"2min 43s" if duration is less than an hour
There is a typo in the method name on 'Detailed' but we prefer to not set this method as obsolete just for a typo.
If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

ToManMonth(AnnualInterest)

Gets a double number of man-months that represents annualInterest. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double ToManMonth(AnnualInterest annualInterest)

Parameters

annualInterest AnnualInterest

The estimated cost per year to leave one or several issues unfixed

Returns

double

ToManMonth(Debt)

Gets a double number of man-months that represents debt. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double ToManMonth(Debt debt)

Parameters

debt Debt

The estimated effort to fix one or several issues

Returns

double

ToManMonth(AnnualInterest?)

Gets a double number of man-months that represents annualInterest. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double? ToManMonth(AnnualInterest? annualInterest)

Parameters

annualInterest AnnualInterest?

The estimated nullable cost per year to leave one or several issues unfixed

Returns

double?

Remarks

If annualInterest is null this method returns null.

ToManMonth(Debt?)

Gets a double number of man-months that represents debt. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double? ToManMonth(Debt? debt)

Parameters

debt Debt?

The estimated nullable cost to fix one or several issues

Returns

double?

Remarks

If debt is null this method returns null.

ToManMonth(TimeSpan?)

Gets a double number of man-months that represents duration. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double? ToManMonth(TimeSpan? duration)

Parameters

duration TimeSpan?

The estimated nullable duration to fix one or several issues

Returns

double?

Remarks

If duration is null this method returns null.

ToManMonth(TimeSpan)

Gets a double number of man-months that represents duration. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double ToManMonth(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

double

ToManMonth(TimeSpan, out int, out TimeSpan)

Gets an integer number of man-months that represents duration. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

int ToManMonth(TimeSpan duration, out int residualDays, out TimeSpan residualHoursMinutesSeconds)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

residualDays int

Out parameter that represents the residual less-than-a-man-months number of man-days

residualHoursMinutesSeconds TimeSpan

Out parameter that represents the residual less-than-a-man-day duration, expressed in hours/minutes/seconds

Returns

int

ToManMonthString(TimeSpan)

Gets a string that represents duration as a number of man-months. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

string ToManMonthString(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

string

Remarks

For example this method can return:
"1m 12d" hours are not shown if duration is at least a man-month
"12d 2h" if duration is less than a man-month

"2:02:43" if duration is less than a man-day
"2min 43s" if duration is less than an hour
If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

ToManMonthStringDetailled(TimeSpan)

Gets a detailed string that represents duration as a number of man-months. The number of man-months is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

string ToManMonthStringDetailled(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

string

Remarks

For example this method can return:
"1m 12d 2:02:43" if duration is at least a man-month
"12d 2:02:43" if duration is less than a man-month

"2:02:43" if duration is less than a man-day
"2min 43s" if duration is less than an hour

There is a typo in the method name on 'Detailed' but we prefer to not set this method as obsolete just for a typo.
If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

ToManYear(AnnualInterest)

Gets a double number of man-years that represents annualInterest. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double ToManYear(AnnualInterest annualInterest)

Parameters

annualInterest AnnualInterest

The estimated cost per year to leave one or several issues unfixed

Returns

double

ToManYear(Debt)

Gets a double number of man-years that represents debt. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double ToManYear(Debt debt)

Parameters

debt Debt

The estimated effort to fix one or several issues

Returns

double

ToManYear(AnnualInterest?)

Gets a double number of man-years that represents annualInterest. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double? ToManYear(AnnualInterest? annualInterest)

Parameters

annualInterest AnnualInterest?

The estimated nullable cost per year to leave one or several issues unfixed

Returns

double?

Remarks

If annualInterest is null this method returns null.

ToManYear(Debt?)

Gets a double number of man-years that represents debt. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double? ToManYear(Debt? debt)

Parameters

debt Debt?

The estimated nullable cost to fix one or several issues

Returns

double?

Remarks

If debt is null this method returns null.

ToManYear(TimeSpan?)

Gets a double number of man-years that represents duration. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double? ToManYear(TimeSpan? duration)

Parameters

duration TimeSpan?

The estimated nullable duration to fix one or several issues

Returns

double?

Remarks

If duration is null this method returns null.

ToManYear(TimeSpan)

Gets a double number of man-years that represents duration. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

double ToManYear(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

double

ToManYear(TimeSpan, out int, out TimeSpan)

Gets an integer number of man-years that represents duration. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

int ToManYear(TimeSpan duration, out int residualDays, out TimeSpan residualHoursMinutesSeconds)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

residualDays int

Out parameter that represents the residual less-than-a-man-years number of man-days

residualHoursMinutesSeconds TimeSpan

Out parameter that represents the residual less-than-a-man-day duration, expressed in hours/minutes/seconds

Returns

int

ToManYearString(TimeSpan)

Gets a string that represents duration as a number of man-years. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

string ToManYearString(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

string

Remarks

For example this method can return:
"1y 2m 12d" hours are not shown if duration is at least a man-year
"2m 12d" hours are not shown if duration is at least a man-month
"12d 2h" if duration is less than a man-month

"2:02:43" if duration is less than a man-day
"2min 43s" if duration is less than an hour
If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

ToManYearStringDetailled(TimeSpan)

Gets a detailed string that represents duration as a number of man-years. The number of man-years is computed from this.DebtSettings.NumberOfWorkHourPerDay and this.DebtSettings.NumberOfWorkDayPerYear.

string ToManYearStringDetailled(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

string

Remarks

For example this method can return:
"1y 2m 12d 2:02:43" if duration is at least a man-years
"1m 12d 2:02:43" if duration is at least a man-month
"12d 2:02:43" if duration is less than a man-month

"2:02:43" if duration is less than a man-day
"2min 43s" if duration is less than an hour

There is a typo in the method name on 'Detailed' but we prefer to not set this method as obsolete just for a typo.
If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

ToMoney(AnnualInterest)

Estimate an amount of money from a annualInterest.

double ToMoney(AnnualInterest annualInterest)

Parameters

annualInterest AnnualInterest

The debt to evaluate as money

Returns

double

A double value that represents an amount of money

Remarks

This IDebtFormatter object has been created from a DebtSettings object.
The amount of money is expressed in this.DebtSettings.Currency and is computed from the setting this.DebtSettings.MoneyPerManHour.
The cents are not shown if the amount of money is greater or equals to 50.

ToMoney(Debt)

Estimate an amount of money from a debt.

double ToMoney(Debt debt)

Parameters

debt Debt

The debt to evaluate as money

Returns

double

A double value that represents an amount of money

Remarks

This IDebtFormatter object has been created from a DebtSettings object.
The amount of money is expressed in this.DebtSettings.Currency and is computed from the setting this.DebtSettings.MoneyPerManHour.
The cents are not shown if the amount of money is greater or equals to 50.

ToMoney(AnnualInterest?)

Estimate an amount of money from a annualInterest.

double? ToMoney(AnnualInterest? annualInterest)

Parameters

annualInterest AnnualInterest?

The nullable annual interest to evaluate as money

Returns

double?

A double value that represents an amount of money

Remarks

This IDebtFormatter object has been created from a DebtSettings object.
The amount of money is expressed in this.DebtSettings.Currency and is computed from the setting this.DebtSettings.MoneyPerManHour.
The cents are not shown if the amount of money is greater or equals to 50.
If annualInterest is null this method returns null.

ToMoney(Debt?)

Estimate an amount of money from a debt.

double? ToMoney(Debt? debt)

Parameters

debt Debt?

The nullable debt to evaluate as money

Returns

double?

A double value that represents an amount of money

Remarks

This IDebtFormatter object has been created from a DebtSettings object.
The amount of money is expressed in this.DebtSettings.Currency and is computed from the setting this.DebtSettings.MoneyPerManHour.
The cents are not shown if the amount of money is greater or equals to 50.
If debt is null this method returns null.

ToMoney(TimeSpan?)

Estimate an amount of money from a duration.

double? ToMoney(TimeSpan? duration)

Parameters

duration TimeSpan?

The duration to evaluate as money

Returns

double?

A double value that represents an amount of money

Remarks

This IDebtFormatter object has been created from a DebtSettings object.
The amount of money is expressed in this.DebtSettings.Currency and is computed from the setting this.DebtSettings.MoneyPerManHour.
The cents are not shown if the amount of money is greater or equals to 50.
If duration is null this method returns null.

ToMoney(TimeSpan)

Estimate an amount of money from a duration.

double ToMoney(TimeSpan duration)

Parameters

duration TimeSpan

The duration to evaluate as money

Returns

double

A double value that represents an amount of money

Remarks

This IDebtFormatter object has been created from a DebtSettings object.
The amount of money is expressed in this.DebtSettings.Currency and is computed from the setting this.DebtSettings.MoneyPerManHour.
The cents are not shown if the amount of money is greater or equals to 50.

ToMoneyString(TimeSpan)

Gets a string shortened with 'K' for thousands and 'M' for millions, that represents an amount of money estimated from a duration.

string ToMoneyString(TimeSpan duration)

Parameters

duration TimeSpan

The duration to evaluate as money

Returns

string

Remarks

This IDebtFormatter object has been created from a DebtSettings object.
The amount of money is expressed in this.DebtSettings.Currency and is computed from the setting this.DebtSettings.MoneyPerManHour.
If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

ToMoneyStringDetailled(TimeSpan)

Gets a string that represents an amount of money estimated from a duration.

string ToMoneyStringDetailled(TimeSpan duration)

Parameters

duration TimeSpan

The duration to evaluate as money

Returns

string

Remarks

This IDebtFormatter object has been created from a DebtSettings object.
The amount of money is expressed in this.DebtSettings.Currency and is computed from the setting this.DebtSettings.MoneyPerManHour.
There is a typo in the method name on 'Detailed' but we prefer to not set this method as obsolete just for a typo.
If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

ToSeverity(AnnualInterest)

Gets a Severity from annualInterest an issue, expressed in man-time per year.

Severity ToSeverity(AnnualInterest annualInterest)

Parameters

annualInterest AnnualInterest

The annual-interest an issue, expressed in man-time per year.

Returns

Severity

Remarks

The Severity value returned, is inferred from severity thresholds defined in this.DebtSettings.
Negative and zero values of annualInterest are valid and lead to Severity.Low returned.

ToString(TimeSpan)

Format the technical duration to a string, according to the DebtSettings.DebtStringFormat.

string ToString(TimeSpan duration)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

Returns

string

A string representing the technical debt estimation formatted

See Also

ToString(TimeSpan, string)

Format the technical duration to a string, according to the format string.

string ToString(TimeSpan duration, string format)

Parameters

duration TimeSpan

The estimated duration to fix one or several issues

format string

The string that contains debt formatting tags defined in DebtStringFormat.

Returns

string

A string representing the technical debt estimation formatted

Remarks

If duration.Ticks is higher than Debt.NDepend.TechnicalDebt.Debt.MAX_TICKS or lower than Debt.NDepend.TechnicalDebt.Debt.MIN_TICKS this method returns the string "overflow".

See Also