npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

absorption

v0.8.0

Published

[![Latest Version](https://img.shields.io/github/release/onigoetz/absorption.svg?style=flat-square)](https://github.com/onigoetz/absorption/releases) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https:/

Downloads

16

Readme

Absorption

Latest Version Software License GitHub Workflow Status Coverage Quality Gate Status NPM Downloads

What is absorption ?

Absorption is a small tool that gives you a knowledge absorption score for a git repository.

This is an approach to answer the questions Who has the knowledge on this repository? and What is the bus factor on this repository?

Like all one dimension metric, this metric is not a silver bullet, by using the last person to modifiy a line of code to define it's owner, we will for example miscalculate if there was a mass reformating on the repository. Also, since we are not language aware, we will measure empty lines and there is no notion of importance of a file.

How does it work ?

The approach we take is for each file in a repository, gather how many lines were written per contributor and when.

Then by using a thresold date (1 year by default) we sort the elements in two buckets : commits made before the thresold and commits made after.

This allows us to go in the last step of the process, sorting all those commits in three categories :

  • Fresh : Code that was modified recently (after the thresold)
  • Fading : Code that was modified before the threshold but by a contributor who was also active more recently
  • Lost : Code that was modified by somebody no longer active on the repository

This, in turn will give you a bus factor : How many people need to stop commiting on a project for it to be in danger. By default

Installation

npm install -g absorption

How to use it

absorption /absolute/path/to/cloned/repository

Will give you useful information already. You can then use the options of the command to fine tune the results.

  • --threshold 6m After what delay do you consider the knowledge lost. starts with a number, followed by 'd' for days, 'w' for weeks, 'm' for months or 'y' for years (1y, 6m, 9w). Defaults to one year.
  • --contributors contributors.json Feed data on contributors, see below for that file's format.
  • --weights weights.json Feed data on file weights, see below for that file's format.
  • --with-media Media files (images, audio and video) are excluded by default from the scan, setting --with-media will include them.
  • --with-lockfiles Lockfiles (package-lock.json, yarn.lock, composer.lock) are excluded by default from the scan, setting --with-lockfiles will include them.
  • --verbose Output lots of debug information
  • --json file.json Output the raw data to a json file. (used in conjunction with --verbose will output raw data per file as well)
  • --max-contributors 10 Allows to customize the number of active contributors displayed in the table (default: 10)
  • --max-lost-contributors 10 Allows to customize the number of lost contributors displayed in the list (default: 10)
  • --branch The branch of repository to scan (default: master)

A more advanced example :

absorption /Users/onigoetz/Sites/Libs/crafty --weights weights.json --contributors contributors.json
Scanning ████████████████████████████████████████ | 100% | 492/492 files

The repository's absorption score is 16% fresh, 84% fading and 0% lost

Fresh/Fading knowledge

 Name               │    Total │    Fresh │   Fading 
────────────────────┼──────────┼──────────┼──────────
 Stéphane Goetz     │  99.51 % │  15.67 % │  83.83 % 
 Vitalii Shapovalov │   0.14 % │   0.14 % │   0.00 % 


Lost knowledge

 Name                                │    Total 
─────────────────────────────────────┼──────────
 Illia Shestakov                     │   0.19 % 
 Marie P-W <[email protected]> │   0.08 % 
 Jonas Renaudot                      │   0.05 % 
 mindhalt <[email protected]>       │   0.03 % 

--contributors contributors.json

[
  {
    "type": "person",
    "name": "Stéphane Goetz",
    "active": true,
    "identities": [
      "Stéphane Goetz <[email protected]>",
      "Stéphane Goetz <[email protected]>",
      "Stéphane Goetz <[email protected]>"
    ]
  },
  {
    "type": "bot",
    "name": "Renovate",
    "identities": ["Renovate Bot <[email protected]>"]
  }
]

The fields:

  • type: "person" or "bot", bots will be excluded from the output.
  • name: This name will be used for display.
  • active: (Optional) Setting this value to true, will move lost knowledge to "fading" knowledge and if false, will move "fresh" and "fading" knowledge to "lost"
  • identities: The list of elements to match the contributors to.

--weights weights.json

The weight that is given to each file can be fine tuned, for example you might want to give a higher ranking to some critical business code in an application. Or give only half the weight to tests.

A weight of 0 for a file will skip its processing entirely.

{
  "**/__tests__/*": 0.5,
  "src/business/**": 2,
  "**/*.js": 1.5
}

How fast is it ?

We have to run a git blame on every file on a repository, on small to medium repositories it takes a few seconds to one minute, on big repositories this can take a few minutes. (I ran it on github.com/babel/babel, with 18'000 files it took a little over 6 minutes on my Mac Mini)

Now the good news is that we create an incremental cache, if you rerun the command, all files that weren't modified can be read from cache.