Skip to content

Conversation

@gonzaM
Copy link
Contributor

@gonzaM gonzaM commented Aug 12, 2025

Fix Review Coverage when the PR has no files

Problem

When a pull request has no files changed, the review coverage calculation was causing a division by zero error, resulting in an undefined coverage percentage.

Solution

Return 0 when total_files is zero, preventing the division by zero error.

Changes

  • File: app/services/builders/review_coverage.rb
    • Added early return with 0 when total_files.zero? in the coverage_percentage method

Testing

  • File: spec/services/builders/review_coverage_spec.rb
    • Added test case for when pull request has no files
    • Verifies that coverage percentage returns 0 and total files changed is 0

Impact

  • Prevents application errors when processing pull requests with no file changes
  • Ensures consistent behavior for edge cases in review coverage calculations
  • Maintains data integrity in metrics reporting

@gonzaM gonzaM requested a review from a team as a code owner August 12, 2025 17:49
@gonzaM gonzaM requested review from rodrieiz and santib and removed request for a team August 12, 2025 17:49
@gonzaM gonzaM merged commit 2c73ec6 into develop Aug 12, 2025
2 checks passed
@gonzaM gonzaM deleted the fix_review_coverage_empty_pr branch August 12, 2025 19:17
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.

4 participants