mirror of
https://github.com/astral-sh/ruff
synced 2026-01-07 22:54:28 -05:00
Fix division by zero error in ecosystem check (#11469)
e.g. https://github.com/astral-sh/ruff/actions/runs/9144809516/job/25143076896?pr=11468 <img width="1388" alt="Screenshot 2024-05-19 at 12 02 15 AM" src="https://github.com/astral-sh/ruff/assets/2586601/0df7cbcd-712c-4ea9-96f5-73f871570525">
This commit is contained in:
@@ -145,7 +145,20 @@ def markdown_check_result(result: Result) -> str:
|
||||
|
||||
# Limit the number of items displayed per project to between 10 and 50
|
||||
# based on the proportion of total changes present in this project
|
||||
max_display_per_project = max(10, int((project_changes / total_changes) * 50))
|
||||
max_display_per_project = max(
|
||||
10,
|
||||
int(
|
||||
(
|
||||
# TODO(zanieb): We take the `max` here to avoid division by zero errors where
|
||||
# `total_changes` is zero but `total_affected_rules` is non-zero so we did not
|
||||
# skip display. This shouldn't really happen and indicates a problem in the
|
||||
# calculation of these values. Instead of skipping entirely when `total_changes`
|
||||
# is zero, we'll attempt to report the results to help diagnose the problem.
|
||||
project_changes / max(total_changes, 1)
|
||||
)
|
||||
* 50
|
||||
),
|
||||
)
|
||||
|
||||
# Limit the number of items displayed per rule to between 5 and the max for
|
||||
# the project based on the number of rules affected (less rules, more per rule)
|
||||
|
||||
Reference in New Issue
Block a user