Limit chain length by number of calls as well as width
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Hello
I like to split my chains when they seem „complex enough“. That doesn't necessarily mean they are long in number of characters, but number of calls is a good indicator.
Eg. this still fits the width, but it's already hard to read due to too many chained calls on the same line:
self.0.take_action(Log).result().map_err(|()| LoggerError)
However, when split into multiple lines, it is easier, because the lines naturally invoke sequential thinking about what happens next.
Is it possible to have a complexity heuristic in addition to width heuristic for small items? And consider it large if it fails either?
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
No files, tests, or entry points are named. Start by examining rustfmt's existing width heuristic and the formatting behavior for the provided chained-call example; the work is complete when an agreed call-count heuristic complements the width limit and its behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100