Skip to content

Commit

Permalink
feat: fixes to use the new solhint version
Browse files Browse the repository at this point in the history
  • Loading branch information
adjisb authored and mvanmeerbeck committed Aug 22, 2023
1 parent fccac70 commit 604c386
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 114 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"prettier": "2.0.5",
"prettier-plugin-solidity": "1.0.0-beta.11",
"readline": "^1.3.0",
"solhint": "^3.3.4",
"solhint": "3.4.1",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "0.8.2",
"ts-node": "^10.9.1",
Expand Down
8 changes: 1 addition & 7 deletions packages/dependency-metatx/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@
"endOfLine": "auto"
}
],
"code-complexity": ["error", 7],
"compiler-version": ["error", "^0.8.0"],
"const-name-snakecase": "off",
"func-name-mixedcase": "off",
"constructor-syntax": "error",
"func-visibility": ["error", {"ignoreConstructors": true}],
"not-rely-on-time": "off",
"no-inline-assembly": "off",
"reason-string": ["warn", {"maxLength": 64}]
"func-named-parameters": ["error", 3]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ contract ERC2771HandlerUpgradeable is Initializable, ERC2771HandlerAbstract {

/// @notice initialize the trusted forwarder address
/// @param forwarder trusted forwarder address or zero to disable it
// solhint-disable-next-line func-name-mixedcase
function __ERC2771Handler_init(address forwarder) internal onlyInitializing {
__ERC2771Handler_init_unchained(forwarder);
}

/// @notice initialize the trusted forwarder address
/// @param forwarder trusted forwarder address or zero to disable it
// solhint-disable-next-line func-name-mixedcase
function __ERC2771Handler_init_unchained(address forwarder) internal onlyInitializing {
_setTrustedForwarder(forwarder);
}
Expand Down
9 changes: 1 addition & 8 deletions packages/example-hardhat/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
"endOfLine": "auto"
}
],
"code-complexity": ["error", 7],
"compiler-version": ["error", "^0.8.0"],
"const-name-snakecase": "off",
"func-name-mixedcase": "off",
"constructor-syntax": "error",
"func-visibility": ["error", {"ignoreConstructors": true}],
"not-rely-on-time": "off",
"no-inline-assembly": "off",
"reason-string": ["warn", {"maxLength": 64}]
"func-visibility": ["error", {"ignoreConstructors": true}]
}
}
11 changes: 7 additions & 4 deletions packages/example-hardhat/contracts/Lock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ pragma solidity ^0.8.9;
// import "hardhat/console.sol";

contract Lock {
uint public unlockTime;
uint256 public unlockTime;
address payable public owner;

event Withdrawal(uint amount, uint when);
event Withdrawal(uint256 amount, uint256 when);

constructor(uint _unlockTime) payable {
require(block.timestamp < _unlockTime, "Unlock time should be in the future");
constructor(uint256 _unlockTime) payable {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp < _unlockTime, "Should be in the future");

unlockTime = _unlockTime;
owner = payable(msg.sender);
Expand All @@ -21,9 +22,11 @@ contract Lock {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);

// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= unlockTime, "You can't withdraw yet");
require(msg.sender == owner, "You aren't the owner");

// solhint-disable-next-line not-rely-on-time
emit Withdrawal(address(this).balance, block.timestamp);

owner.transfer(address(this).balance);
Expand Down
11 changes: 7 additions & 4 deletions packages/example-hardhat/contracts/LockUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Ini

///@dev This contract is used as an example of an upgradeable contract
contract LockUpgradeable is Initializable {
uint public unlockTime;
uint256 public unlockTime;
address payable public owner;

event Withdrawal(uint amount, uint when);
event Withdrawal(uint256 amount, uint256 when);

function initialize(uint _unlockTime) external payable initializer {
require(block.timestamp < _unlockTime, "Unlock time should be in the future");
function initialize(uint256 _unlockTime) external payable initializer {
// solhint-disable-next-line not-rely-on-time
require(block.timestamp < _unlockTime, "Should be in the future");

unlockTime = _unlockTime;
owner = payable(msg.sender);
Expand All @@ -24,9 +25,11 @@ contract LockUpgradeable is Initializable {
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);

// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= unlockTime, "You can't withdraw yet");
require(msg.sender == owner, "You aren't the owner");

// solhint-disable-next-line not-rely-on-time
emit Withdrawal(address(this).balance, block.timestamp);

owner.transfer(address(this).balance);
Expand Down
2 changes: 1 addition & 1 deletion packages/example-hardhat/test/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('LockUpgradable', function () {
const latestTime = await time.latest();
const Lock = await ethers.getContractFactory('Lock');
await expect(Lock.deploy(latestTime, {value: 1})).to.be.revertedWith(
'Unlock time should be in the future'
'Should be in the future'
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/example-hardhat/test/lockUpgradable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('LockUpgradable', function () {
const Lock = await ethers.getContractFactory('LockUpgradeable');
const lock = await Lock.deploy();
await expect(lock.initialize(latestTime, {value: 1})).to.be.revertedWith(
'Unlock time should be in the future'
'Should be in the future'
);
});

Expand Down
8 changes: 2 additions & 6 deletions packages/giveaway/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
"endOfLine": "auto"
}
],
"code-complexity": ["error", 7],
"func-named-parameters": "off",
"compiler-version": ["error", "^0.8.0"],
"const-name-snakecase": "off",
"func-name-mixedcase": "off",
"constructor-syntax": "error",
"func-visibility": ["error", {"ignoreConstructors": true}],
"not-rely-on-time": "off",
"no-inline-assembly": "off",
"reason-string": ["warn", {"maxLength": 64}]
"not-rely-on-time": "off"
}
}
1 change: 1 addition & 0 deletions packages/giveaway/contracts/test/FakeProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ contract FakeProxy is ERC1967UpgradeUpgradeable {
}

function _delegate(address implementation) internal virtual {
// solhint-disable-next-line no-inline-assembly
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
Expand Down
Loading

1 comment on commit 604c386

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

84.07%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
packages/core/src/solc_0.8.15/common/BaseWithStorage/ERC2771
   ERC2771HandlerUpgradeable.sol44.44%25%60%44.44%23, 27, 30, 39, 39, 39–40, 42
packages/core/src/solc_0.8.15/common/OperatorFilterer
   IOperatorFilterRegistry.sol100%100%100%100%
   UpdatableOperatorFiltererUpgradeable.sol11.11%10%25%9.52%18, 23–24, 24, 24–25, 27, 27, 27–28, 30, 38, 38, 38, 42, 42, 42–44, 46, 46, 46–47, 50, 55, 55, 55–56, 56, 56–57, 60, 68, 68, 68–69, 71
packages/core/src/solc_0.8.15/raffle
   DanceFight.sol75%50%100%100%20
   FistOfTheNorthStar.sol75%50%100%100%20
   GenericRaffle.sol61.32%41.11%58.62%81.72%177, 188–194, 224–228, 251–258, 265–266, 269, 287, 287–288, 288, 288–289, 307, 335–336, 346, 346–347, 347, 347–349, 357–358, 380, 389, 397–398, 408, 408–409, 418, 418, 420, 429, 429, 431, 441, 441–442, 452, 452–453, 464, 464–465, 565, 574, 625–626, 629, 632
   HellsKitchen.sol75%50%100%100%20
   MadBalls.sol75%50%100%100%20
   ParisHilton.sol75%50%100%100%20
   Rabbids.sol75%50%100%100%20
packages/core/src/solc_0.8/Game
   GameBaseToken.sol87.78%74.26%100%95.60%101, 139–140, 142–143, 185, 189, 189–190, 193–194, 213, 216–217, 231, 248, 251, 266, 286, 352, 415, 420, 436, 441–442, 442, 442–443, 485–486, 507–508, 510, 523, 523, 523, 523, 523, 542, 547, 55, 618, 81
   GameMinter.sol96.15%83.33%100%100%77
   GameV1.sol100%100%100%100%
packages/core/src/solc_0.8/OperatorFilterer/contracts
   OperatorFilterRegistrant.sol62.50%50%100%66.67%17, 19–20
packages/core/src/solc_0.8/OperatorFilterer/contracts/upgradeable
   DefaultOperatorFiltererUpgradeable.sol0%0%0%0%12, 12–13
   OperatorFiltererUpgradeable.sol88.64%85%100%90%16, 52–53, 62–63
packages/core/src/solc_0.8/OperatorFilterer/interfaces
   IOperatorFilterRegistry.sol100%100%100%100%
packages/core/src/solc_0.8/Sand
   SandBaseToken.sol100%100%100%100%
packages/core/src/solc_0.8/StarterPack
   PurchaseValidator.sol95.12%83.33%100%100%29, 37
   StarterPackV2.sol92.96%82.35%95.65%99.07%108–111, 309, 378, 67–72, 84
packages/core/src/solc_0.8/Utils
   Batch.sol85.48%59.09%100%100%34, 38, 44, 50, 56, 65, 75, 82, 88
packages/core/src/solc_0.8/asset
   AssetAttributesRegistry.sol66.91%56%83.33%71.43%103, 103, 103–104, 104, 109, 109, 109–112, 112, 112–113, 116, 118–119, 121, 123, 151–152, 160–161, 169–171, 185, 200–201, 201, 201–202, 202, 202–203, 205, 205, 205–206, 228, 232, 67, 69–70
   AssetMinter.sol85.71%73.75%87.50%94.34%113, 117, 137, 137, 137–138, 138, 141–142, 226, 235, 248, 284, 284–285, 287, 415, 44–46, 53–54, 65, 70, 75, 80, 85
   AssetSignedAuctionWithAuth.sol78%65.15%84.62%88.73%109, 111, 180, 180, 193, 202, 211, 227, 227, 240, 249, 258, 272, 285, 298, 303, 307–308, 311–312, 316, 346–347, 347, 347, 351–352, 352, 352, 373, 89
   AssetUpgrader.sol80.81%61.76%84.62%92.31%113–114, 122, 127, 168, 192–193, 195, 221, 221–222, 224, 232, 76–77, 96–97
packages/core/src/solc_0.8/asset/libraries
   AssetHelper.sol0%0%0%0%16–17, 17, 17–18, 18, 18–19, 35–38, 40, 47, 49, 51, 59–60, 62, 65–67, 67, 67–72, 72, 72–74, 78, 86, 88–90, 90, 90–91, 94
   ERC1155ERC721Helper.sol100%100%100%100%
packages/core/src/solc_0.8/assetERC1155
   AssetBaseERC1155.sol80.12%65.45%83.72%88.76%110, 112, 133, 152, 152, 152, 152, 152–153, 179, 190, 196, 204, 204, 204, 204, 204, 216, 218, 263, 301, 301, 301–304, 317–318, 339, 355, 355, 355–356, 358, 367, 369–370, 390, 437, 447–449, 449, 449–450, 452, 491,

Please sign in to comment.