`forge fmt` minor unexpected formatting results
Component
Forge
Have you ensured that all of these are up to date?
- [X] Foundry
- [ ] Foundryup
What version of Foundry are you on?
forge 0.2.0 (cce3a44 2022-07-20T00:34:27.703293Z)
What command(s) is the bug in?
forge fmt
Operating System
Windows
Describe the bug
Hello there!
Nothing major but I believe the formatting is a bit odd in some cases. Two cases I noticed:
-
Opening brace goes to the next line when the line is long (but not too long!):
Before:
if (something() || somethingElse() || anotherThing() || someOtherThin()) { return false; }After:
if (something() || somethingElse() || anotherThing() || someOtherThin()) { return false; }Curiously, if the last function in the expression is
someOtherTh(), which would still make the line length go past 80, the line stays the same, and if it'ssomeOtherThing(), it works as expected by moving the expression to the next line. -
Binary operators seem to always be positioned at the same column when breaking long expressions into multiple lines:
This one I'm less sure than the first one about whether it's a bug or just something that's not currenty implemented but will be.
Before:
bool somethingElse = something == 2 || something == 3 || something == 5 || something == 7 || something == 11;After:
bool somethingElse = something == 2 || something == 3 || something == 5 || something == 7 || something == 11;
That's it. By the way, I've been trying out forge and it's been a great experience. Good work!
Here is a similar example but even more extreme: https://github.com/sambacha/dappspec/blob/master/solidity/src/Recommendations/Large-Integers.md
cc @rkrasiuk / @jpopesculian unsure if this is still the case
I was hoping that the linter would allow one line conditionals. Going to append this here as a comment for now instead of making a new issue.
@ewilz currently we support this only in yul blocks. feel free to open a feature request for fmt config option
Everything here appears to be resolved now, so closing this