mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00
Fix division by zero error in ecosystem check (#11469)
e.g.2514307689
<img width="1388" alt="Screenshot 2024-05-19 at 12 02 15 AM" src="0df7cbcd
-712c-4ea9-96f5-73f871570525">
This commit is contained in:
parent
d9ec3d56b0
commit
46fcd19ca6
1 changed files with 14 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue