From ffa61c4717c6827357c11ee1c351e3158f7dc5a2 Mon Sep 17 00:00:00 2001 From: chapati Date: Wed, 21 Feb 2024 09:22:56 +0100 Subject: [PATCH] chore: fixed solhint warnings (#374) ### What Fixed relevant and disabled irrelevant solhint warnings ### Review Check solhint passes without any warnings now --------- Co-authored-by: bowd --- .prettierrc.yml | 14 ++++++++- contracts/governance/GovernanceFactory.sol | 4 ++- contracts/governance/MentoGovernor.sol | 31 ++++++++++++++----- contracts/governance/TimelockController.sol | 4 ++- .../governance/deployers/ProxyDeployerLib.sol | 4 ++- .../tokens/patched/ERC20PermitUpgradeable.sol | 2 ++ contracts/tokens/patched/ERC20Upgradeable.sol | 6 ++++ package.json | 4 +-- test/fork-tests/BaseForkTest.t.sol | 1 + test/fork-tests/TokenUpgrade.t.sol | 1 + test/utils/BaseTest.next.sol | 1 + test/utils/BaseTest.t.sol | 1 + test/utils/Factory.sol | 7 +++-- 13 files changed, 64 insertions(+), 16 deletions(-) diff --git a/.prettierrc.yml b/.prettierrc.yml index de8227a..d393101 100644 --- a/.prettierrc.yml +++ b/.prettierrc.yml @@ -9,6 +9,18 @@ trailingComma: "all" overrides: - files: ["*.sol"] options: - compiler: ">=0.5.13" + compiler: "0.5.17" tabWidth: 2 printWidth: 120 + - files: ["contracts/tokens/patched/*.sol"] + options: + compiler: "0.8.18" + - files: ["contracts/tokens/StableTokenV2.sol"] + options: + compiler: "0.8.18" + - files: ["contracts/governance/**/*.sol"] + options: + compiler: "0.8.18" + - files: ["test/**/*.sol"] + options: + compiler: "" diff --git a/contracts/governance/GovernanceFactory.sol b/contracts/governance/GovernanceFactory.sol index 7ebc094..314a6bf 100644 --- a/contracts/governance/GovernanceFactory.sol +++ b/contracts/governance/GovernanceFactory.sol @@ -18,7 +18,9 @@ import { MentoTokenDeployerLib } from "./deployers/MentoTokenDeployerLib.sol"; import { TimelockControllerDeployerLib } from "./deployers/TimelockControllerDeployerLib.sol"; import { ProxyDeployerLib } from "./deployers/ProxyDeployerLib.sol"; -import { TransparentUpgradeableProxy } from "openzeppelin-contracts-next/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + TransparentUpgradeableProxy +} from "openzeppelin-contracts-next/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { ProxyAdmin } from "openzeppelin-contracts-next/contracts/proxy/transparent/ProxyAdmin.sol"; import { Ownable } from "openzeppelin-contracts-next/contracts/access/Ownable.sol"; diff --git a/contracts/governance/MentoGovernor.sol b/contracts/governance/MentoGovernor.sol index 862db0b..866aa35 100644 --- a/contracts/governance/MentoGovernor.sol +++ b/contracts/governance/MentoGovernor.sol @@ -2,13 +2,30 @@ pragma solidity 0.8.18; // solhint-disable max-line-length -import { GovernorUpgradeable, IGovernorUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/GovernorUpgradeable.sol"; -import { GovernorSettingsUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorSettingsUpgradeable.sol"; -import { GovernorCompatibilityBravoUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/compatibility/GovernorCompatibilityBravoUpgradeable.sol"; -import { GovernorVotesUpgradeable, IVotesUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorVotesUpgradeable.sol"; -import { GovernorVotesQuorumFractionUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorVotesQuorumFractionUpgradeable.sol"; -import { GovernorTimelockControlUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorTimelockControlUpgradeable.sol"; -import { TimelockControllerUpgradeable, IERC165Upgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/TimelockControllerUpgradeable.sol"; +import { + GovernorUpgradeable, + IGovernorUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/governance/GovernorUpgradeable.sol"; +import { + GovernorSettingsUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorSettingsUpgradeable.sol"; +import { + GovernorCompatibilityBravoUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/governance/compatibility/GovernorCompatibilityBravoUpgradeable.sol"; +import { + GovernorVotesUpgradeable, + IVotesUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorVotesUpgradeable.sol"; +import { + GovernorVotesQuorumFractionUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorVotesQuorumFractionUpgradeable.sol"; +import { + GovernorTimelockControlUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/governance/extensions/GovernorTimelockControlUpgradeable.sol"; +import { + TimelockControllerUpgradeable, + IERC165Upgradeable +} from "openzeppelin-contracts-upgradeable/contracts/governance/TimelockControllerUpgradeable.sol"; /** * @title Mento Governor diff --git a/contracts/governance/TimelockController.sol b/contracts/governance/TimelockController.sol index 76cf654..1c4e498 100644 --- a/contracts/governance/TimelockController.sol +++ b/contracts/governance/TimelockController.sol @@ -2,7 +2,9 @@ pragma solidity 0.8.18; // solhint-disable-next-line max-line-length -import { TimelockControllerUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/governance/TimelockControllerUpgradeable.sol"; +import { + TimelockControllerUpgradeable +} from "openzeppelin-contracts-upgradeable/contracts/governance/TimelockControllerUpgradeable.sol"; /** * @title TimelockController diff --git a/contracts/governance/deployers/ProxyDeployerLib.sol b/contracts/governance/deployers/ProxyDeployerLib.sol index 24ba9af..0b1243f 100644 --- a/contracts/governance/deployers/ProxyDeployerLib.sol +++ b/contracts/governance/deployers/ProxyDeployerLib.sol @@ -2,7 +2,9 @@ pragma solidity 0.8.18; //solhint-disable-next-line max-line-length -import { TransparentUpgradeableProxy } from "openzeppelin-contracts-next/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { + TransparentUpgradeableProxy +} from "openzeppelin-contracts-next/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { ProxyAdmin } from "openzeppelin-contracts-next/contracts/proxy/transparent/ProxyAdmin.sol"; library ProxyDeployerLib { diff --git a/contracts/tokens/patched/ERC20PermitUpgradeable.sol b/contracts/tokens/patched/ERC20PermitUpgradeable.sol index fad35bb..7855d70 100644 --- a/contracts/tokens/patched/ERC20PermitUpgradeable.sol +++ b/contracts/tokens/patched/ERC20PermitUpgradeable.sol @@ -51,10 +51,12 @@ abstract contract ERC20PermitUpgradeable is ERC20Upgradeable, IERC20PermitUpgrad * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ + // solhint-disable-next-line func-name-mixedcase function __ERC20Permit_init(string memory name) internal onlyInitializing { __EIP712_init_unchained(name, "1"); } + // solhint-disable-next-line func-name-mixedcase function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {} /** diff --git a/contracts/tokens/patched/ERC20Upgradeable.sol b/contracts/tokens/patched/ERC20Upgradeable.sol index 96d2aed..cb6ea64 100644 --- a/contracts/tokens/patched/ERC20Upgradeable.sol +++ b/contracts/tokens/patched/ERC20Upgradeable.sol @@ -40,6 +40,7 @@ import "openzeppelin-contracts-next/contracts/access/Ownable.sol"; * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Ownable, Initializable, IERC20Upgradeable, IERC20MetadataUpgradeable { + // solhint-disable var-name-mixedcase address private __deprecated_registry_storage_slot__; string private _name; string private _symbol; @@ -52,6 +53,8 @@ contract ERC20Upgradeable is Ownable, Initializable, IERC20Upgradeable, IERC20Me uint256[4] private __deprecated_inflationState_storage_slot__; bytes32 private __deprecated_exchangeRegistryId_storage_slot__; + // solhint-enable var-name-mixedcase + /** * @dev Sets the values for {name} and {symbol}. * @@ -61,10 +64,13 @@ contract ERC20Upgradeable is Ownable, Initializable, IERC20Upgradeable, IERC20Me * All two of these values are immutable: they can only be set once during * construction. */ + + // solhint-disable-next-line func-name-mixedcase function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } + // solhint-disable-next-line func-name-mixedcase function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; diff --git a/package.json b/package.json index 8308de8..aff0a03 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "postinstall": "husky install", "prettier": "prettier --config \"./.prettierrc.yml\" --write \"**/*.{json,md,sol,yml}\" --list-different", "prettier:check": "prettier --config \"./.prettierrc.yml\" --check \"**/*.{json,md,sol,yml}\"", - "solhint": "solhint --config \"./.solhint.json\" \"{contracts,test,script}/**/*.sol\"", - "solhint:check": "solhint --config \"./.solhint.json\" \"{contracts,test,script}/**/*.sol\" -q", + "solhint": "solhint --config \"./.solhint.json\" \"{contracts,test,script}/**/*.sol\" -w 0", + "solhint:check": "solhint --config \"./.solhint.json\" \"{contracts,test,script}/**/*.sol\" -w 0 -q", "test": "forge test", "fork-test": "env FOUNDRY_PROFILE=fork-tests forge test", "fork-test:baklava": "env FOUNDRY_PROFILE=fork-tests forge test --match-contract Baklava", diff --git a/test/fork-tests/BaseForkTest.t.sol b/test/fork-tests/BaseForkTest.t.sol index fd77539..830ac13 100644 --- a/test/fork-tests/BaseForkTest.t.sol +++ b/test/fork-tests/BaseForkTest.t.sol @@ -99,6 +99,7 @@ contract BaseForkTest is Test, TokenHelpers, TestAsserts { // Use this by running tests like: // env ONLY={exchangeId} yarn fork-tests:baklava + // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory data) = address(vm).call(abi.encodeWithSignature("envBytes32(string)", "ONLY")); bytes32 exchangeIdFilter; if (success) { diff --git a/test/fork-tests/TokenUpgrade.t.sol b/test/fork-tests/TokenUpgrade.t.sol index 71235e5..68e3517 100644 --- a/test/fork-tests/TokenUpgrade.t.sol +++ b/test/fork-tests/TokenUpgrade.t.sol @@ -12,6 +12,7 @@ contract TokenUpgradeForkTest is Test { address public constant REGISTRY_ADDRESS = 0x000000000000000000000000000000000000ce10; IRegistry public registry = IRegistry(REGISTRY_ADDRESS); + // solhint-disable-next-line func-name-mixedcase function test_upgrade() public { uint256 forkId = vm.createFork("celo_mainnet"); vm.selectFork(forkId); diff --git a/test/utils/BaseTest.next.sol b/test/utils/BaseTest.next.sol index 0f3f086..f3acf10 100644 --- a/test/utils/BaseTest.next.sol +++ b/test/utils/BaseTest.next.sol @@ -13,6 +13,7 @@ contract BaseTest is Test { address public constant REGISTRY_ADDRESS = 0x000000000000000000000000000000000000ce10; IRegistry public registry = IRegistry(REGISTRY_ADDRESS); + // solhint-disable-next-line const-name-snakecase address public constant deployer = address(0x31337); Factory public factory; diff --git a/test/utils/BaseTest.t.sol b/test/utils/BaseTest.t.sol index 3a53fb9..28e920e 100644 --- a/test/utils/BaseTest.t.sol +++ b/test/utils/BaseTest.t.sol @@ -11,6 +11,7 @@ contract BaseTest is Test { address public constant REGISTRY_ADDRESS = 0x000000000000000000000000000000000000ce10; IRegistry public registry = IRegistry(REGISTRY_ADDRESS); + // solhint-disable-next-line const-name-snakecase address public constant deployer = address(0x31337); Factory public factory; diff --git a/test/utils/Factory.sol b/test/utils/Factory.sol index 8962f99..d4c51e6 100644 --- a/test/utils/Factory.sol +++ b/test/utils/Factory.sol @@ -18,12 +18,13 @@ interface MiniVM { */ contract Factory { address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code")))); - MiniVM internal constant vm = MiniVM(VM_ADDRESS); + MiniVM internal constant VM = MiniVM(VM_ADDRESS); function createFromPath(string memory _path, bytes memory args) public returns (address) { - bytes memory bytecode = abi.encodePacked(vm.getCode(_path), args); + bytes memory bytecode = abi.encodePacked(VM.getCode(_path), args); address addr; + // solhint-disable-next-line no-inline-assembly assembly { addr := create(0, add(bytecode, 0x20), mload(bytecode)) } @@ -43,7 +44,7 @@ contract Factory { bytes memory args ) public { address addr = createContract(_contract, args); - vm.etch(dest, GetCode.at(addr)); + VM.etch(dest, GetCode.at(addr)); console.log("Etched %s to %s", _contract, dest); } }