Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better auto-indenting #5

Open
mhluongo opened this issue Jul 9, 2020 · 3 comments
Open

Better auto-indenting #5

mhluongo opened this issue Jul 9, 2020 · 3 comments

Comments

@mhluongo
Copy link
Member

mhluongo commented Jul 9, 2020

Inserting a new-line in the middle of an arg list or event indents incorrectly for default linting rules in ethlint.

Similarly, when this snippet below is auto-formatted with = in visual mode...

for (uint i = 0; i < numTokens; i++) {
    uint256 idealBalance = D1.mul(balances0[i]).div(D0);
    uint256 difference = idealBalance.difference(balances1[i]);
    fees[i] = _fee.mul(difference).div(FEE_DENOMINATOR);
    balances[i] = balances1[i].sub(fees[i].mul(_adminFee).div(
        FEE_DENOMINATOR));
    balances1[i] = balances1[i].sub(fees[i]);
}

the indent yields

for (uint i = 0; i < numTokens; i++) {
    uint256 idealBalance = D1.mul(balances0[i]).div(D0);
    uint256 difference = idealBalance.difference(balances1[i]);
    fees[i] = _fee.mul(difference).div(FEE_DENOMINATOR);
    balances[i] = balances1[i].sub(fees[i].mul(_adminFee).div(
        FEE_DENOMINATOR));
        balances1[i] = balances1[i].sub(fees[i]);
}

Not ideal.

@fvictorio
Copy link
Contributor

(Yet another unsolicited comment)

Have you tried prettier-solidity? It stills has some way to go, but it could really use the push of being used by a high profile project like tbtc. Formatting is a PITA (we removed styling rules in solhint for that reason), and I think it would be great if the community would move towards a unique formatting tool.

(This is my last bikeshedding, at least for today!)

@Shadowfiend
Copy link

I'm planning on slapping prettier-solidity onto all Keep and tBTC code in the extremely near future for both CI and precommit formatting, independently of Matt's work here :) I've already poked at it and despite any imperfections, it's a big boon.

@fvictorio
Copy link
Contributor

@Shadowfiend glad to hear that! Feel free to open an issue for any imperfection you find, even bikeshedding is welcome 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants