Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT(CodeChurn): Add method to return lines added and removed per file #299

Merged

Conversation

BrenoFariasdaSilva
Copy link

This PR introduces a new method, get_added_and_removed_lines(), in the CodeChurn class that provides the number of lines added and removed per file across commits in a repository. The new method returns a dictionary where each key is the file path, and the value is a tuple (added_lines, removed_lines) representing the total added and removed lines for that file.

Changes made:

  • New method get_added_and_removed_lines():
    • Added a method to return a dictionary with file paths as keys and a tuple (added_lines, removed_lines) as values.
    • Refactored the _initialize() method to store both added and removed lines for each modified file.
  • Updated documentation:
    • Updated the Code Churn documentation to include the new feature.
  • Added unit tests:
    • Introduced tests to verify the accuracy of the get_added_and_removed_lines() method, ensuring correct results across multiple commits.

Impact:

This change enhances the CodeChurn metric class by allowing users to directly retrieve detailed information on code churn, specifically the number of lines added and removed for each file.

Linked Issue:

This PR is related to and resolves Issue #298, which requested a feature to provide a way to access the number of lines added and removed per file in a commit.

Breno Farias added 3 commits September 20, 2024 13:14
- Implemented `get_added_and_removed_lines()` method in the CodeChurn class.
- The new method returns a dictionary with file paths as keys and a tuple (added_lines, removed_lines) as values.
- Refactored `_initialize()` to store added and removed lines for each modified file.
- Enhanced the class to support easier access to detailed code churn metrics, allowing users to directly retrieve the number of lines added and removed in each commit.
@ishepard
Copy link
Owner

ishepard commented Oct 2, 2024

LGTM! Sorry it took me so long to get to this, I missed the notification.

There's an error with MyPy, could you fix that?
The error in TestPulse instead you can neglect

@BrenoFariasdaSilva
Copy link
Author

BrenoFariasdaSilva commented Oct 4, 2024

Hi @ishepard, no worries about the delay!
I noticed the issue when I initially submitted the PR, left the browser tab open with the intention of fixing it later, and ended up forgetting about it. It's a simple fix, and I've already taken care of it. 😊

Copy link

codecov bot commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.26%. Comparing base (aed5f5b) to head (98431bb).
Report is 12 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #299      +/-   ##
==========================================
+ Coverage   97.25%   97.26%   +0.01%     
==========================================
  Files          17       17              
  Lines        1091     1097       +6     
==========================================
+ Hits         1061     1067       +6     
  Misses         30       30              
Files with missing lines Coverage Δ
pydriller/metrics/process/code_churn.py 100.00% <100.00%> (ø)

@ishepard
Copy link
Owner

ishepard commented Oct 4, 2024

LGTM! Thanks for the work and the PR!

@ishepard ishepard merged commit 51510ab into ishepard:master Oct 4, 2024
4 of 19 checks passed
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.

Feature Request: Add Method to Retrieve Lines Added and Removed in Code Churn Metrics.
2 participants