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

Expected indentation of N spaces but found M #354

Closed
developerasun opened this issue Sep 4, 2022 · 1 comment
Closed

Expected indentation of N spaces but found M #354

developerasun opened this issue Sep 4, 2022 · 1 comment

Comments

@developerasun
Copy link

developerasun commented Sep 4, 2022

Problem
I'm using Turborepo and Github Actions for test automation in CI. And Hardhat-solhint throws indentation error, which automatically disappears when the action re-runs.

pawcon-blockchain:lint:   113:5    error    Expected indentation of 0 spaces but found 4                    indent
pawcon-blockchain:lint:   115:5    error    Expected indentation of 0 spaces but found 4                    indent
pawcon-blockchain:lint:   115:14   error    Expected indentation of 0 spaces but found 13                   indent
pawcon-blockchain:lint:   115:30   error    Expected indentation of 0 spaces but found 29                   indent
pawcon-blockchain:lint:   115:31   error    Expected indentation of 0 spaces but found 30                   indent
pawcon-blockchain:lint:   115:33   error    Expected indentation of 0 spaces but found 32                   indent
pawcon-blockchain:lint:   115:42   error    Expected indentation of 0 spaces but found 41                   indent
pawcon-blockchain:lint:   115:47   error    Expected indentation of 0 spaces but found 46                   indent
pawcon-blockchain:lint:   115:55   error    Expected indentation of 0 spaces but found 54                   indent
pawcon-blockchain:lint:   115:56   error    Expected indentation of 0 spaces but found 55                   indent
pawcon-blockchain:lint:   115:63   error    Expected indentation of 0 spaces but found 62                   indent
pawcon-blockchain:lint:   115:65   error    Expected indentation of 0 spaces but found 64                   indent
...

pawcon-blockchain:lint: ✖ 422 problems (389 errors, 33 warnings)

This is my dependency, using @nomiclabs/hardhat-solhint ^2.0.1

"devDependencies": {
    "@chainlink/contracts": "^0.4.1",
    "@defi-wonderland/smock": "^2.2.0",
    "@ethersproject/abi": "^5.0.0",
    "@ethersproject/abstract-provider": "5",
    "@ethersproject/abstract-signer": "5",
    "@ethersproject/bytes": "^5.0.0",
    "@ethersproject/providers": "^5.0.0",
    "@nomicfoundation/hardhat-chai-matchers": "^1.0.2",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.3",
    "@nomicfoundation/hardhat-toolbox": "^1.0.2",
    "@nomiclabs/hardhat-ethers": "^2.0.6",
    "@nomiclabs/hardhat-etherscan": "^3.1.0",
    "@nomiclabs/hardhat-solhint": "^2.0.1",
    "@openzeppelin/contracts": "^4.6.0",
    "@openzeppelin/contracts-upgradeable": "^4.7.0",
    "@openzeppelin/hardhat-upgrades": "^1.19.0",
    "@typechain/ethers-v5": "10.1.0",
    "@typechain/hardhat": "6.1.2",
    "@types/chai": "^4.3.1",
    "@types/mocha": "^9.1.1",
    "@types/node": "^12.20.55",
    "@typescript-eslint/eslint-plugin": "^4.33.0",
    "@typescript-eslint/parser": "^4.33.0",
    "alchemy-sdk": "^2.0.3",
    "async": "^3.2.4",
    "chai": "^4.3.6",
    "chalk": "4.1.2",
    "dotenv": "^16.0.1",
    "eslint": "^7.32.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-config-standard": "^16.0.3",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-promise": "^4.2.1 || ^5.0.0",
    "ethers": "^5.6.9",
    "hardhat": "^2.9.9",
    "hardhat-contract-sizer": "^2.5.1",
    "hardhat-gas-reporter": "^1.0.8",
    "hardhat-log-remover": "^2.0.2",
    "install": "^0.13.0",
    "lodash": "^4.17.15",
    "mocha": "^10.0.0",
    "node-html-parser": "5.4.2-0",
    "nodemon": "^2.0.15",
    "prettier": ">=2.0.0",
    "prettier-plugin-solidity": "1.0.0-beta.19",
    "solidity-coverage": "^0.7.21",
    "solidity-docgen": "0.6.0-beta.22",
    "ts-node": "^10.8.1",
    "typechain": "8.1.0",
    "typescript": "^4.7.4"
  },

and I configurate .solhint.json like below

{
  "extends": "solhint:recommended",
  "rules": {
    "compiler-version": ["error", ">=0.8.0"],
    "func-visibility": ["error", { "ignoreConstructors": true }],
    "avoid-sha3": "error",
    "avoid-suicide": "error",
    "avoid-thorw": "error",
    "avoid-tx-origin": "warn",
    "check-send-result": "error",
    "multiple-sends": "error",
    "no-complex-fallback": "error",
    "no-inline-assembly": "warn",
    "not-rely-on-block-hash": "error",
    "not-rely-on-time": "warn",
    "reentrancy": "error",
    "state-visibility": "warn",
    "max-states-count": "error",
    "no-empty-blocks": "warn",
    "no-unused-vars": "warn",
    "payable-fallback": "error",
    "reason-string": "warn",
    "const-name-snakecase": "warn"
  }
}

Also, I noticed that ignoreConstructors option does not work for constructor. For example, if I run solhint in CLI, it throws below func-visibility error.

pawcon-monorepo/apps/blockchain/contracts/pool/SingleCatnipPool.sol
   37:40  warning  Variable name must be in mixedCase                              var-name-mixedcase
   46:19  error    Explicitly mark visibility in function                          func-visibility

And then the 46th code line was constructor, which should be ignored by the .solhint.json.

constructor() {
        _ERC1820_REGISTRY = IERC1820RegistryUpgradeable(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
        initERC1820Registry();
    }

With the above configurations, sometimes CI passes without problem, sometimes throws indentation error. I appreciate any help in advance!

@dbale-altoros
Copy link
Collaborator

dbale-altoros commented Aug 16, 2023

@developerasun
I will close this issue
This indentation error is ESLINT related, not solhint

Also, the ignore constructor option it's working now...
check screen on
#320

Thanks a lot for posting.
Feel free to open any issue if you find any bug or have any improvement idea!!!

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

2 participants