Skip to content

fix: exclude deleted files from code_density calculation#392

Open
t7929375-eng wants to merge 1 commit intoentrius:testfrom
t7929375-eng:fix/exclude-deleted-files-from-density
Open

fix: exclude deleted files from code_density calculation#392
t7929375-eng wants to merge 1 commit intoentrius:testfrom
t7929375-eng:fix/exclude-deleted-files-from-density

Conversation

@t7929375-eng
Copy link
Copy Markdown

Summary

When a PR deletes files, the deleted files are correctly scored at 0 (scoring_method='skipped') in tree_sitter_scoring.py, but their total_lines (set to file.deletions) are still included in the total_lines sum in scoring.py:172.

Since code_density = token_score / total_lines, deleted files inflate the denominator without contributing to the numerator, artificially deflating code_density and reducing the base_score for all miners whose PRs include file deletions.

This fix filters out skipped (deleted) files from the total_lines calculation so that code_density accurately reflects only the scored content.

Example: A PR with 50 lines of dense code (token_score=80) that also removes a 200-line file would get code_density = 80/250 = 0.32 instead of the correct 80/50 = 1.6 — a 5x penalty.

Type of Change

  • Bug fix

Testing

  • ruff check passes
  • pyright passes
  • Self-reviewed

Checklist

  • Code follows project style guidelines
  • Self-review completed

cc @anderdc @LandynDev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant