diff --git a/python/ruff-ecosystem/ruff_ecosystem/check.py b/python/ruff-ecosystem/ruff_ecosystem/check.py index bebbe97a62953..680b5f204d3c8 100644 --- a/python/ruff-ecosystem/ruff_ecosystem/check.py +++ b/python/ruff-ecosystem/ruff_ecosystem/check.py @@ -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)