Keep track of number of warnings in CI and fail if this increases/changes
As part of our post-mortem, we identified that one of the challenges was to keep track of some compiler warnings in our smart contracts. In our CI builds, we need to keep track of number of warnings in CI and fail if this increases/changes.
@clemsos I think it would be good to revisit that at some point. Now that we are getting audited, I think it would be worth trying to be a bit more strict about these.
Some warnings, taken from a recent build:
contracts/past-versions/UnlockV6.sol:1162:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _purchaser, // solhint-disable-line no-unused-vars
^----------------^
contracts/past-versions/UnlockV6.sol:1163:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _keyPrice // solhint-disable-line no-unused-vars
^------------^
contracts/past-versions/UnlockV6.sol:1183:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _referrer // solhint-disable-line no-unused-vars
^---------------^
contracts/past-versions/UnlockV6.sol:1219:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _tokens // solhint-disable-line no-unused-vars
^----------^
contracts/past-versions/UnlockV4.sol:2643:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _purchaser, // solhint-disable-line no-unused-vars
^----------------^
contracts/past-versions/UnlockV4.sol:2644:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _keyPrice // solhint-disable-line no-unused-vars
^------------^
contracts/past-versions/UnlockV4.sol:2664:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _referrer // solhint-disable-line no-unused-vars
^---------------^
contracts/past-versions/UnlockV4.sol:2682:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _tokens // solhint-disable-line no-unused-vars
^----------^
contracts/past-versions/UnlockV3.sol:2491:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _purchaser, // solhint-disable-line no-unused-vars
^----------------^
contracts/past-versions/UnlockV3.sol:2492:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _keyPrice // solhint-disable-line no-unused-vars
^------------^
contracts/past-versions/UnlockV3.sol:2512:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _referrer // solhint-disable-line no-unused-vars
^---------------^
contracts/past-versions/UnlockV3.sol:2530:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _tokens // solhint-disable-line no-unused-vars
^----------^
contracts/past-versions/UnlockV1.sol:2230:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _purchaser, // solhint-disable-line no-unused-vars
^----------------^
contracts/past-versions/UnlockV1.sol:2231:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _keyPrice // solhint-disable-line no-unused-vars
^------------^
contracts/past-versions/UnlockV1.sol:2251:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _referrer // solhint-disable-line no-unused-vars
^---------------^
contracts/past-versions/UnlockV1.sol:2269:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _tokens // solhint-disable-line no-unused-vars
^----------^
contracts/past-versions/PublicLockV0.sol:496:3: Warning: Functions in interfaces should be declared external.
function onERC721Received(
^ (Relevant source part starts here and spans across multiple lines).
contracts/past-versions/PublicLockV0.sol:1159:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address operator, // solhint-disable-line no-unused-vars
^--------------^
contracts/past-versions/PublicLockV0.sol:1160:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address from, // solhint-disable-line no-unused-vars
^----------^
contracts/past-versions/PublicLockV0.sol:1161:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint tokenId, // solhint-disable-line no-unused-vars
^----------^
contracts/past-versions/PublicLockV0.sol:1162:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
bytes data // solhint-disable-line no-unused-vars
^--------^
contracts/past-versions/UnlockV0.sol:496:3: Warning: Functions in interfaces should be declared external.
function onERC721Received(
^ (Relevant source part starts here and spans across multiple lines).
contracts/past-versions/UnlockV0.sol:1159:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address operator, // solhint-disable-line no-unused-vars
^--------------^
contracts/past-versions/UnlockV0.sol:1160:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address from, // solhint-disable-line no-unused-vars
^----------^
contracts/past-versions/UnlockV0.sol:1161:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint tokenId, // solhint-disable-line no-unused-vars
^----------^
contracts/past-versions/UnlockV0.sol:1162:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
bytes data // solhint-disable-line no-unused-vars
^--------^
contracts/past-versions/UnlockV0.sol:1404:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _purchaser, // solhint-disable-line no-unused-vars
^----------------^
contracts/past-versions/UnlockV0.sol:1405:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _keyPrice // solhint-disable-line no-unused-vars
^------------^
contracts/past-versions/UnlockV0.sol:1425:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
address _referrer // solhint-disable-line no-unused-vars
^---------------^
contracts/past-versions/UnlockV0.sol:1443:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
uint _tokens // solhint-disable-line no-unused-vars
^----------^
Warning: This declaration shadows an existing declaration.
--> contracts/ERC20Patched.sol:1720:25:
|
1720 | function initialize(string memory name, string memory symbol, uint8 decimals) public virtual initializer {
| ^^^^^^^^^^^^^^^^^^
Note: The shadowed declaration is here:
--> contracts/ERC20Patched.sol:1726:5:
|
1726 | function name() public view virtual returns (string memory) {
| ^ (Relevant source part starts here and spans across multiple lines).
Warning: This declaration shadows an existing declaration.
--> contracts/ERC20Patched.sol:1720:45:
|
1720 | function initialize(string memory name, string memory symbol, uint8 decimals) public virtual initializer {
| ^^^^^^^^^^^^^^^^^^^^
Note: The shadowed declaration is here:
--> contracts/ERC20Patched.sol:1730:5:
|
1730 | function symbol() public view virtual returns (string memory) {
| ^ (Relevant source part starts here and spans across multiple lines).
Warning: This declaration shadows an existing declaration.
--> contracts/ERC20Patched.sol:1720:67:
|
1720 | function initialize(string memory name, string memory symbol, uint8 decimals) public virtual initializer {
| ^^^^^^^^^^^^^^
Note: The shadowed declaration is here:
--> contracts/ERC20Patched.sol:1734:5:
|
1734 | function decimals() public view virtual returns (uint8) {
| ^ (Relevant source part starts here and spans across multiple lines).
Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> contracts/ERC20Patched.sol:997:43:
|
997 | function __ERC20Permit_init_unchained(string memory name) internal initializer {
| ^^^^^^^^^^^^^^^^^^
Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> contracts/ERC20Patched.sol:1001:40:
|
1001 | function __ERC20Permit_init_unsafe(string memory name) internal {
| ^^^^^^^^^^^^^^^^^^
Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> @openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol:42:43:
|
42 | function __ERC20Permit_init_unchained(string memory name) internal onlyInitializing {
| ^^^^^^^^^^^^^^^^^^
And some linter warnings:
contracts/interfaces/hooks/ILockKeyPurchaseHook.sol
43:3 warning Function order is incorrect, external function can not go after external view function (line 23) ordering
contracts/interfaces/IPublicLock.sol
34:3 warning Function name must be in mixedCase func-name-mixedcase
35:3 warning Function name must be in mixedCase func-name-mixedcase
36:3 warning Function name must be in mixedCase func-name-mixedcase
49:3 warning Function order is incorrect, external function can not go after external pure function (line 42) ordering
contracts/interfaces/IUnlock.sol
36:3 warning Function order is incorrect, external function can not go after external view function (line 21) ordering
162:5 warning Variable name must be in mixedCase var-name-mixedcase
239:3 warning '__initializeOwnable' should not start with _ private-vars-leading-underscore
contracts/mixins/MixinDisable.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
30:3 warning Function order is incorrect, modifier definition can not go after internal function (line 23) ordering
38:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
47:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinERC721Enumerable.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
35:3 warning Function order is incorrect, public view function can not go after internal function (line 18) ordering
35:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
51:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
74:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinFunds.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
57:3 warning Function order is incorrect, state variable declaration can not go after internal function (line 40) ordering
57:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinGrantKeys.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
22:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
60:3 warning Function order is incorrect, state variable declaration can not go after external function (line 22) ordering
60:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinKeys.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
38:3 warning Function order is incorrect, state variable declaration can not go after event definition (line 32) ordering
38:3 warning 'keyByOwner' should start with _ private-vars-leading-underscore
60:3 warning 'approved' should start with _ private-vars-leading-underscore
67:3 warning 'managerToOperatorApproved' should start with _ private-vars-leading-underscore
129:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
143:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
167:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
180:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
192:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
206:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
237:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
257:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
273:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
382:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
422:4 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
423:6 warning Error message for require is too long reason-string
434:4 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
438:4 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinLockCore.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
59:3 warning Function order is incorrect, state variable declaration can not go after event definition (line 55) ordering
79:3 warning 'BASIS_POINTS_DEN' should start with _ private-vars-leading-underscore
117:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
135:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
171:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
194:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
206:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
224:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
234:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
244:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinLockMetadata.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
31:3 warning 'lockSymbol' should start with _ private-vars-leading-underscore
34:3 warning 'baseTokenURI' should start with _ private-vars-leading-underscore
54:3 warning Function order is incorrect, external function can not go after internal function (line 40) ordering
54:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
65:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
78:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
92:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
109:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
115:5 warning Variable name must be in mixedCase var-name-mixedcase
169:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinPurchase.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
28:3 warning Function order is incorrect, state variable declaration can not go after event definition (line 25) ordering
34:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
41:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
58:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
100:7 warning Error message for require is too long reason-string
125:5 warning Code contains empty blocks no-empty-blocks
156:28 warning Avoid to use low level calls avoid-low-level-calls
167:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
199:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinRefunds.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
44:3 warning Function order is incorrect, external function can not go after internal function (line 34) ordering
44:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
58:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
71:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
92:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
167:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinRoles.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
39:3 warning Function order is incorrect, modifier definition can not go after internal function (line 22) ordering
40:5 warning Error message for require is too long reason-string
45:5 warning Error message for require is too long reason-string
51:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
55:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
60:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
67:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
71:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
76:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
81:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/mixins/MixinTransfer.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
33:3 warning Function order is incorrect, state variable declaration can not go after event definition (line 28) ordering
47:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
111:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
152:7 warning Error message for require is too long reason-string
178:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
208:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
229:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
245:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
263:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
314:3 warning Variable name must be in mixedCase var-name-mixedcase
contracts/PublicLock.sol
2:1 warning Compiler version ^0.8.4 does not satisfy the ^0.5.4 semver requirement compiler-version
42:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
68:3 warning Function order is incorrect, receive function can not go after public function (line 42) ordering
68:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
68:30 warning Code contains empty blocks no-empty-blocks
contracts/Unlock.sol
2:1 warning Compiler version ^0.8.7 does not satisfy the ^0.5.4 semver requirement compiler-version
40:1 warning Contract has 16 states declarations but allowed no more than 15 max-states-count
63:3 warning Function order is incorrect, state variable declaration can not go after modifier definition (line 58) ordering
99:3 warning 'proxyAdmin' should start with _ private-vars-leading-underscore
141:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
153:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
171:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
178:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
187:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
208:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
246:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
272:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
276:5 warning Error message for require is too long reason-string
281:5 warning Error message for require is too long reason-string
285:5 warning Error message for require is too long reason-string
303:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
319:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
331:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
428:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
440:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
450:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
455:5 warning Variable name must be in mixedCase var-name-mixedcase
476:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
498:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
511:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
526:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
537:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
contracts/UnlockDiscountToken.sol
20:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
contracts/UnlockDiscountTokenV2.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
26:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
27:7 warning Error message for require is too long reason-string
contracts/UnlockDiscountTokenV3.sol
2:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
contracts/UnlockProtocolGovernor.sol
2:1 warning Compiler version ^0.8.2 does not satisfy the ^0.5.4 semver requirement compiler-version
18:3 warning Explicitly mark visibility of state state-visibility
19:3 warning Explicitly mark visibility of state state-visibility
20:3 warning Explicitly mark visibility of state state-visibility
22:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
38:3 warning Function order is incorrect, event definition can not go after public function (line 22) ordering
56:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
62:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
68:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
contracts/UnlockProtocolTimelock.sol
2:1 warning Compiler version ^0.8.4 does not satisfy the ^0.5.4 semver requirement compiler-version
7:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
contracts/utils/Clone2Factory.sol
2:1 warning Compiler version ^0.8.2 does not satisfy the ^0.5.4 semver requirement compiler-version
27:5 warning Avoid to use inline assembly. It is acceptable only in rare cases no-inline-assembly
contracts/utils/LockSerializer.sol
2:1 warning Compiler version ^0.8.2 does not satisfy the ^0.5.4 semver requirement compiler-version
9:3 warning Explicitly mark visibility in function (Set ignoreConstructors to true if using solidity >=0.7.0) func-visibility
9:18 warning Code contains empty blocks no-empty-blocks
11:3 warning Function order is incorrect, event definition can not go after constructor (line 9) ordering
69:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
82:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
93:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
108:3 warning All public or external methods in a contract must override a definition from an interface comprehensive-interface
111:5 warning Error message for require is too long reason-string
contracts/utils/UnlockContextUpgradeable.sol
4:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
18:5 warning Function name must be in mixedCase func-name-mixedcase
22:5 warning Function name must be in mixedCase func-name-mixedcase
22:67 warning Code contains empty blocks no-empty-blocks
31:5 warning Function order is incorrect, state variable declaration can not go after internal view function (line 28) ordering
contracts/utils/UnlockInitializable.sol
4:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
39:5 warning 'initialized' should start with _ private-vars-leading-underscore
44:5 warning 'initializing' should start with _ private-vars-leading-underscore
53:9 warning Error message for require is too long reason-string
73:9 warning Error message for require is too long reason-string
contracts/utils/UnlockOwnable.sol
4:1 warning Compiler version ^0.8.0 does not satisfy the ^0.5.4 semver requirement compiler-version
30:5 warning '__initializeOwnable' should not start with _ private-vars-leading-underscore
45:5 warning Function order is incorrect, modifier definition can not go after public view function (line 38) ordering
73:7 warning Error message for require is too long reason-string
✖ 177 problems (0 errors, 177 warnings)
lots of these are for past versions of Unlock. As for the lint errors, we have #6129 to track it so I think we can close this