ruff/crates/ruff_cli/src
konsti aafde6db28
Remove some indexing (#6728)
**Summary** A common pattern in the code used to be
```rust
if statements.len() != 1 {
    return;
}
use_single_entry(statements[0])?;
```
which can be better expressed as
```rust
let [statement] = statements else {
    return;
};
use_single_entry(statements)?;
```

Direct indexing can cause panics if you don't manually take care of
checking the length, while matching (such as if-let or let-else) can
never panic.

This isn't a complete refactor, i've just removed some of the obvious
cases. I've specifically looked for `.len() != 1` and fixed those.

**Test Plan** No functional changes
2023-08-21 16:56:15 +02:00
..
bin Replace .map_or(false, $closure) with .is_some_and(closure) (#6244) 2023-08-01 19:29:42 +02:00
commands Refactor SourceKind to store file content (#6640) 2023-08-18 13:45:38 +00:00
args.rs Extend ruff_dev formatter script to compute statistics and format a project (#5492) 2023-07-07 11:30:12 +00:00
cache.rs Refactor SourceKind to store file content (#6640) 2023-08-18 13:45:38 +00:00
diagnostics.rs Refactor SourceKind to store file content (#6640) 2023-08-18 13:45:38 +00:00
lib.rs Remove some indexing (#6728) 2023-08-21 16:56:15 +02:00
panic.rs Disallow unreachable_pub (#4314) 2023-05-11 18:00:00 -04:00
printer.rs Refactor SourceKind to store file content (#6640) 2023-08-18 13:45:38 +00:00
resolve.rs Log configuration in ruff_dev (#6193) 2023-07-31 17:52:38 +00:00