-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
This lint would warn when a user uses std::fs::OpenOptions
or tokio::fs::OpenOptions
and calls both write
and append
Lint Name
no_write_and_append
Category
correctness, suspicious, pedantic
Advantage
- Remove
write
call that doesn't have any affect
Drawbacks
Some people might do this deliberately to highlight that writes are enabled.
Example
use std::fs::OpenOptions;
fn main() {
let file = OpenOptions::new()
.create(true)
.write(true) // useless `write` call, `append` will make it writable anyway
.append(true)
.open("dump.json")
.unwrap();
}
Could be written as:
use std::fs::OpenOptions;
fn main() {
let file = OpenOptions::new()
.create(true)
.append(true)
.open("dump.json")
.unwrap();
}
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints