ruff/crates/ruff_cli
Charlie Marsh 195c000f5a
Avoid failed assertion when showing fixes from stdin (#8029)
## Summary

When linting, we store a map from file path to fixes, which we then use
to show a fix summary in the printer.

In the printer, we assume that if the map is non-empty, then we have at
least one fix. But this isn't enforced by the fix struct, since you can
have an entry from (file path) to (empty fix table). In practice, this
only bites us when linting from `stdin`, since when linting across
multiple files, we have an `AddAssign` on `Diagnostics` that avoids
adding empty entries to the map. When linting from `stdin`, we create
the map directly, and so it _is_ possible to have a non-empty map that
doesn't contain any fixes, leading to a panic.

This PR introduces a dedicated struct to make these constraints part of
the formal interface.

Closes https://github.com/astral-sh/ruff/issues/8027.

## Test Plan

`cargo test` (notice two failures are removed)
2023-10-17 21:50:39 -04:00
..
resources/test/fixtures Fix gitignore to not ignore files that are required (#7538) 2023-09-21 21:33:09 +02:00
src Avoid failed assertion when showing fixes from stdin (#8029) 2023-10-17 21:50:39 -04:00
tests Avoid failed assertion when showing fixes from stdin (#8029) 2023-10-17 21:50:39 -04:00
Cargo.toml Bump version to 0.1.0 (#7931) 2023-10-16 13:06:48 -05:00