Skip to content

Commit

Permalink
chore: fixed solhint warnings (#374)
Browse files Browse the repository at this point in the history
### What
Fixed relevant and disabled irrelevant solhint warnings

### Review
Check solhint passes without any warnings now

---------

Co-authored-by: bowd <[email protected]>
  • Loading branch information
chapati23 and bowd authored Feb 21, 2024
1 parent c443a13 commit ffa61c4
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 16 deletions.
14 changes: 13 additions & 1 deletion .prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
4 changes: 3 additions & 1 deletion contracts/governance/GovernanceFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
31 changes: 24 additions & 7 deletions contracts/governance/MentoGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion contracts/governance/TimelockController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion contracts/governance/deployers/ProxyDeployerLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions contracts/tokens/patched/ERC20PermitUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

/**
Expand Down
6 changes: 6 additions & 0 deletions contracts/tokens/patched/ERC20Upgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
*
Expand All @@ -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_;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions test/fork-tests/BaseForkTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions test/fork-tests/TokenUpgrade.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions test/utils/BaseTest.next.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions test/utils/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 4 additions & 3 deletions test/utils/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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);
}
}

0 comments on commit ffa61c4

Please sign in to comment.