rust-lang / rust-lang/rust-clippy
Replace `if s.split('.').count() == 1` with `if !s.contains('.')`
Open
Nobody has claimed this yet.
A-lint
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
I've found this "ingenious" snippet in a big Rust codebase, and Clippy didn't catch it.
Lint Name
str-split-count-1
Example
if url.split('|').count() == 1 {
}
Could be written as:
if !url.contains('.') {
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Clippy lint implementation and tests for the proposed str-split-count-1 lint, then compare the issue's split-count example with the requested contains replacement. Done means the lint recognizes the single-delimiter split/count pattern and offers the equivalent contains-based suggestion with coverage for the shown Rust example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100