Skip to content

Implement the Bus Factor Algorithm (v0.1) Math #26

Description

@SHAURYASANYAL3

🛑 The Problem

We need the actual mathematical business logic to calculate the 'Bus Factor' (the minimum number of developers responsible for 50% of the repository's total commits or lines changed).

💡 The Solution

Write a pure, testable TypeScript function that takes raw commit data and returns the exact integer representing the Bus Factor.

🛠️ Implementation Details

  1. Create the function in packages/domain-analytics/src/busFactor.ts.
  2. Group the total commits by author.
  3. Sum the commits (or lines changed) per author.
  4. Sort the authors descending by volume.
  5. Iterate through the list, keeping a running tally of commits.
  6. The moment the tally exceeds Total Commits / 2, return the current index + 1 as the Bus Factor.

✅ Acceptance Criteria

  • The algorithm is mathematically sound.
  • Pure function (no database calls inside it).
  • 100% unit test coverage for edge cases (e.g., 1 author, 0 authors, perfectly even distribution among 10 authors).

Ready to tackle this? Comment .take below to get automatically assigned!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions