emacs-solidity icon indicating copy to clipboard operation
emacs-solidity copied to clipboard

Constructor body idents too many levels

Open clarkhenry opened this issue 4 years ago • 1 comments

When using a constructor with many arguments, such that each argument should drop to its own line, the body of the constructor has too many levels of indentation.

The same is not true of a function having the same arguments. That is, functions still format the body correctly, regardless of the style of the function declaration.

The following code demonstrates the issue with the style/format of the constructor:

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";


contract SolidityModeExample {

    IERC20 public tokenA;
    IERC20 public tokenB;
    IERC20 public tokenC;
    IERC20 public tokenD;

    /// @dev The body of this constructor is indented too far, by 8 spaces
    constructor (
        address _tokenA,
        address _tokenB,
        address _tokenC,
        address _tokenD
    )
        public
            {
                tokenA = IERC20(_tokenA);
                tokenB = IERC20(_tokenB);
                tokenC = IERC20(_tokenC);
                tokenD = IERC20(_tokenD);
            }

    /// @dev The body of this function is indented correctly
    function updateTokens (
        address _tokenA,
        address _tokenB,
        address _tokenC,
        address _tokenD
    )
        public
    {
        tokenA = IERC20(_tokenA);
        tokenB = IERC20(_tokenB);
        tokenC = IERC20(_tokenC);
        tokenD = IERC20(_tokenD);
    }
}

clarkhenry avatar Oct 09 '21 04:10 clarkhenry

yea, the whole indentation of this mode makes little sense so far..

hellwolf avatar Jan 03 '23 14:01 hellwolf