Skip to content

Add MagicNumberCheck detector with unit and team-scale tests#51

Closed
aliyahnurdafika wants to merge 2 commits intodevfrom
feature/magic-number-check
Closed

Add MagicNumberCheck detector with unit and team-scale tests#51
aliyahnurdafika wants to merge 2 commits intodevfrom
feature/magic-number-check

Conversation

@aliyahnurdafika
Copy link
Copy Markdown
Collaborator

Summary

Implements the first violation detector: MagicNumberCheck, designed to be testable and safe on real GitHub diff data.

What’s included

  • New detector: src/violations/magic_number_check.py
  • Package init: src/violations/__init__.py
  • Tests:
    • test/test_magic_number_check.py (controlled unit tests on synthetic snippets)
    • test/test_magic_number_team15_patch_fixture.py (single real Team 15 patch_snippet fixture)
    • test/test_magic_number_team_scaled_csv.py (iterates all Team 15 patch_snippet rows from CSV via MAGIC_NUMBER_PATCH_CSV)

How to test

pytest -q test/test_magic_number_check.py
pytest -q test/test_magic_number_team15_patch_fixture.py
MAGIC_NUMBER_PATCH_CSV=data/csv/year-long-project-team-15/year-long-project-team-15_commit_file_changes.csv \
pytest -q test/test_magic_number_team_scaled_csv.py

Notes:

  • The team-scale test intentionally sweeps all patch_snippet rows to ensure diff hunk headers (@@ -a,b +c,d @@) are not treated as code.
  • Documentation (documentation/violations.md) will be submitted in a separate PR as requested.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey Aliyah, could you add a brief description of what the "MagicNumber" violation is here? thanks!

@aliyahnurdafika
Copy link
Copy Markdown
Collaborator Author

Hi everyone, just a quick update. I’m pivoting away from the patch-snippet-based approach and will continue the MagicNumber work using full-file enrichment for better context.
I just pushed a new commit (“Update PR extraction and add full-file enrichment support”) that adds scripts/enrich_full_files.py and updates src/extractors/pull_request_extractor.py.
For review, please focus on these two files/commit for the new direction. Thank you!

@Mahatav
Copy link
Copy Markdown
Collaborator

Mahatav commented Feb 23, 2026

Sounds good. I would close this PR and open a new PR when the new feature is ready.

@aliyahnurdafika
Copy link
Copy Markdown
Collaborator Author

Hi @Mahatav , thank you for the comment. The new feature is ready in PR #72 . And I'll close this PR.

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.

3 participants