techdebt
Utils function to compute technical debt metrics and display them on the support of your choice.
Install
npm install --save-dev techdebt
Get started
This package is nothing more than an aggregation of helpers to get, save and display metrics.
It helps you to easily write a small script that computes metrics representing your technical debt. A good idea would be to run this script during continuous integration so that it updates a technical debt dashboard or Slack channel.
Simple example: display the todo comments in Slack
const techdebt = const slackClient = const fsHelper = slackClient techdebt
More complex example: display the historic of todos count in Slack
Sometimes it's useful to get the history of a metric and display it as a graph. To save a metric you can use any API that you like. The simplest API I found is datadog that allows to save metrics and take a snapshot of a graph of the metric.
const techdebt = const slackClient = const fsHelper = slackClientdatadogClient techdebt
API doc
main
techdebt.run(metrics)
Takes an array of metrics and return a promise of formated metrics.
Example:
const techdebt = techdebt
Metric
get: Function save: Function format: Function
get()
A function that fetch the metric value. It returns a value of any type (you'll have to handle the value).
It can return a value or the promise of a value.
Example:
fsHelper
save(metricValue) (optional)
A function that save the value on a third party tool such as Datadog, Google Spreadsheet etc.
If it returns a promise, the format function will wait for this promise to be resolved before execution.
Example:
const save = datadogClient
format(metricValue)
A function that format the value as expected.
Example:
title: 'Todos count in code' text: metricValue
Clients
Slack
slackClient.initialize(options)
Initialize the client with options
Example:
const slackClient = slackClient
slackClient.post(title, attachments)
Post attachments to Slack.
Datadog
Using this client requires to install dogapi package:
npm install --save-dev dogapi
datadogClient.initialize(options)
const datadogClient = datadogClient
Codecov
codecovClient.initialize(options)
const codecovClient = codecovClient
codecovClient.get()
Return a promise on the last code coverage ratio.
codecovClient
datadogClient.post(metricName, metricValue, timestamp)
Post a metric value that will be saved to datadog and wait for the metric to be fetchable (datadog has a delay in serving posted metrics).
The timestamp attribute is optional (default is now)
It returns a promise that resolves when the metric is saved.
datadogClient.get(metricName, period)
Get the snapshot of a graph of a metric.
It returns a promise of the URL of the snapshot image.
write an issue
missing a client? Trello, Google sheet ? PleaseHelpers
packages
This helper requires to install npm-check
npm install --save-dev npm-check
This helper allow you to know which of your dependencies are unused or need upgrades
packages.get(type)
type can be one of major
, minor
, unused
, upToDate
.
It returns a promise of the list of packages corresponding to the type.
packages.slackFormat(type, packages)
Returns a predefined Slack attachment format
Example:
const slackClient = const packages = const techdebt = slackClient techdebt
fsHelper
A librairy of helper functions to analyse source files.
fsHelper.readRecursively(root)
Get the recursive list of files in a directory.
Example:
fsHelper
fsHelper.countLines(root, options)
Sum the lines of files in a directory (recursively). You can specify an extension in the options. The returned value is a promise of the line count.
Example:
fsHelper
fsHelper.countRegex(root, regex, options)
Sum the number of occurence if a regex in a directory (recursively). You can specify an extension in the options. The returned value is a promise of the count.
Example:
fsHelper
const slackClient = const datadogClient = const fsHelper = const techdebt = slackClientdatadogClient techdebt
fsHelper.getRegexMatches(root, regex, options)
Get the matches of a regex in a directory (recursively). You can specify an extension in the options. The returned value is a promise of the matches.
Example:
fsHelper