foundry-rs / foundry-rs/foundry
forge(fmt): Align function/struct parameters
- Dominant language
- Rust
- Stars
- 10.6k
- Forks
- 2.6k
- Avg merge
- 16h 38m
- Merged PRs (30d)
- 511
Description
### Component
Forge
### Describe the feature you would like
Basically I'm envisioning this having 4 rules for functions:
1. Only align items with the same function used, and when there are no line breaks in between them.
2. Left-justify all lines to the character length of the longest item from the previous parameter.
3. Align all params with each other.
4. Break into multiline syntax with a line break above if the alignment causes a line to become too long.
For structs, it would just be rule 2 for all the params in the struct.
Here's some examples of some diffs of me doing this manually:



Multi-param alignment demonstrated below
```solidity
vm.serializeUint(keyLongerLength, 'baseRateConversion', strategy.baseRateConversion());
vm.serializeUint(key, 'borrowSpread', strategy.borrowSpread());
vm.serializeUint(key, 'supplySpread', strategy.supplySpread());
vm.serializeUint(key, 'maxRate', strategy.maxRate());
```
### Additional context
_No response_
Contributor guide
Research direction
Start by locating Forge's formatting entry point and the formatter handling Solidity function and struct parameters. Use the four function-alignment rules, the struct rule, and the shown multi-parameter example as behavioral requirements; done means formatting produces the requested alignment without exceeding the line length.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, solidity
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100