Skip to content

Commit 76abd1a

Browse files
authored
Replaced Solium in favor of Solhint (#1575)
* Adding solhint, working on style fixes. * Upgraded to solhint 1.5.0. * Removed all references to Solium * Updated mocks to make the pass the new linter rules. * Reformatted the .solhint.json file a bit. * Removed Solium configuration files. * Remove Solium dependency. * Add comment explaing disabled time rule in TokenVesting. * Revert to the old (ugly?) style. * Revert SignatureBouncerMock style. * Fix ERC165InterfacesSupported interface.
1 parent 35d7039 commit 76abd1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+881
-1013
lines changed

.solhint.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "default",
3+
"rules": {
4+
"indent": ["error", 4],
5+
6+
"bracket-align": false,
7+
"compiler-fixed": false,
8+
"no-simple-event-func-name": false,
9+
"two-lines-top-level-separator": false
10+
}
11+
}

.soliumignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.soliumrc.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

contracts/crowdsale/Crowdsale.sol

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ contract Crowdsale is ReentrancyGuard {
6363
_token = token;
6464
}
6565

66-
// -----------------------------------------
67-
// Crowdsale external interface
68-
// -----------------------------------------
69-
7066
/**
7167
* @dev fallback function ***DO NOT OVERRIDE***
7268
* Note that other contracts will transfer fund with a base gas stipend
@@ -130,12 +126,9 @@ contract Crowdsale is ReentrancyGuard {
130126
_postValidatePurchase(beneficiary, weiAmount);
131127
}
132128

133-
// -----------------------------------------
134-
// Internal interface (extensible)
135-
// -----------------------------------------
136-
137129
/**
138-
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use `super` in contracts that inherit from Crowdsale to extend their validations.
130+
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.
131+
* Use `super` in contracts that inherit from Crowdsale to extend their validations.
139132
* Example from CappedCrowdsale.sol's _preValidatePurchase method:
140133
* super._preValidatePurchase(beneficiary, weiAmount);
141134
* require(weiRaised().add(weiAmount) <= cap);
@@ -148,16 +141,18 @@ contract Crowdsale is ReentrancyGuard {
148141
}
149142

150143
/**
151-
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
144+
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid
145+
* conditions are not met.
152146
* @param beneficiary Address performing the token purchase
153147
* @param weiAmount Value in wei involved in the purchase
154148
*/
155149
function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
156-
// optional override
150+
// solhint-disable-previous-line no-empty-blocks
157151
}
158152

159153
/**
160-
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
154+
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends
155+
* its tokens.
161156
* @param beneficiary Address performing the token purchase
162157
* @param tokenAmount Number of tokens to be emitted
163158
*/
@@ -166,7 +161,8 @@ contract Crowdsale is ReentrancyGuard {
166161
}
167162

168163
/**
169-
* @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send tokens.
164+
* @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send
165+
* tokens.
170166
* @param beneficiary Address receiving the tokens
171167
* @param tokenAmount Number of tokens to be purchased
172168
*/
@@ -175,12 +171,13 @@ contract Crowdsale is ReentrancyGuard {
175171
}
176172

177173
/**
178-
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
174+
* @dev Override for extensions that require an internal state to check for validity (current user contributions,
175+
* etc.)
179176
* @param beneficiary Address receiving the tokens
180177
* @param weiAmount Value in wei involved in the purchase
181178
*/
182179
function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
183-
// optional override
180+
// solhint-disable-previous-line no-empty-blocks
184181
}
185182

186183
/**

contracts/crowdsale/distribution/FinalizableCrowdsale.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@ contract FinalizableCrowdsale is TimedCrowdsale {
4545
* should call super._finalization() to ensure the chain of finalization is
4646
* executed entirely.
4747
*/
48-
function _finalization() internal {}
48+
function _finalization() internal {
49+
// solhint-disable-previous-line no-empty-blocks
50+
}
4951
}

contracts/crowdsale/price/IncreasingPriceCrowdsale.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
5959
return 0;
6060
}
6161

62-
// solium-disable-next-line security/no-block-members
62+
// solhint-disable-next-line not-rely-on-time
6363
uint256 elapsedTime = block.timestamp.sub(openingTime());
6464
uint256 timeRange = closingTime().sub(openingTime());
6565
uint256 rateRange = _initialRate.sub(_finalRate);

contracts/crowdsale/validation/PausableCrowdsale.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import "../../lifecycle/Pausable.sol";
88
* @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role.
99
*/
1010
contract PausableCrowdsale is Crowdsale, Pausable {
11-
1211
/**
13-
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
12+
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.
13+
* Use super to concatenate validations.
1414
* Adds the validation that the crowdsale must not be paused.
1515
* @param _beneficiary Address performing the token purchase
1616
* @param _weiAmount Value in wei involved in the purchase

contracts/crowdsale/validation/TimedCrowdsale.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ contract TimedCrowdsale is Crowdsale {
2727
* @param closingTime Crowdsale closing time
2828
*/
2929
constructor (uint256 openingTime, uint256 closingTime) public {
30-
// solium-disable-next-line security/no-block-members
30+
// solhint-disable-next-line not-rely-on-time
3131
require(openingTime >= block.timestamp);
3232
require(closingTime > openingTime);
3333

@@ -53,7 +53,7 @@ contract TimedCrowdsale is Crowdsale {
5353
* @return true if the crowdsale is open, false otherwise.
5454
*/
5555
function isOpen() public view returns (bool) {
56-
// solium-disable-next-line security/no-block-members
56+
// solhint-disable-next-line not-rely-on-time
5757
return block.timestamp >= _openingTime && block.timestamp <= _closingTime;
5858
}
5959

@@ -62,7 +62,7 @@ contract TimedCrowdsale is Crowdsale {
6262
* @return Whether crowdsale period has elapsed
6363
*/
6464
function hasClosed() public view returns (bool) {
65-
// solium-disable-next-line security/no-block-members
65+
// solhint-disable-next-line not-rely-on-time
6666
return block.timestamp > _closingTime;
6767
}
6868

contracts/cryptography/ECDSA.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ library ECDSA {
2626
// Divide the signature in r, s and v variables
2727
// ecrecover takes the signature parameters, and the only way to get them
2828
// currently is to use assembly.
29-
// solium-disable-next-line security/no-inline-assembly
29+
// solhint-disable-next-line no-inline-assembly
3030
assembly {
3131
r := mload(add(signature, 0x20))
3232
s := mload(add(signature, 0x40))
@@ -42,7 +42,6 @@ library ECDSA {
4242
if (v != 27 && v != 28) {
4343
return (address(0));
4444
} else {
45-
// solium-disable-next-line arg-overflow
4645
return ecrecover(hash, v, r, s);
4746
}
4847
}

contracts/drafts/ERC1046/TokenMetadata.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import "../../token/ERC20/IERC20.sol";
66
* @title ERC-1047 Token Metadata
77
* @dev See https://eips.ethereum.org/EIPS/eip-1046
88
* @dev tokenURI must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047
9-
* @dev TODO - update https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC721/IERC721.sol#L17 when 1046 is finalized
109
*/
1110
contract ERC20TokenMetadata is IERC20 {
1211
function tokenURI() external view returns (string memory);

contracts/drafts/SignatureBouncer.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ contract SignatureBouncer is SignerRole {
4343
// Signature size is 65 bytes (tightly packed v + r + s), but gets padded to 96 bytes
4444
uint256 private constant _SIGNATURE_SIZE = 96;
4545

46-
constructor () internal {}
46+
constructor () internal {
47+
// solhint-disable-previous-line no-empty-blocks
48+
}
4749

4850
/**
4951
* @dev requires that a valid signature of a signer was provided

contracts/drafts/TokenVesting.sol

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* solium-disable security/no-block-members */
2-
31
pragma solidity ^0.5.0;
42

53
import "../token/ERC20/SafeERC20.sol";
@@ -13,6 +11,12 @@ import "../math/SafeMath.sol";
1311
* owner.
1412
*/
1513
contract TokenVesting is Ownable {
14+
// The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is
15+
// therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore,
16+
// it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a cliff
17+
// period of a year and a duration of four years, are safe to use.
18+
// solhint-disable not-rely-on-time
19+
1620
using SafeMath for uint256;
1721
using SafeERC20 for IERC20;
1822

@@ -22,6 +26,7 @@ contract TokenVesting is Ownable {
2226
// beneficiary of tokens after they are released
2327
address private _beneficiary;
2428

29+
// Durations and timestamps are expressed in UNIX time, the same units as block.timestamp.
2530
uint256 private _cliff;
2631
uint256 private _start;
2732
uint256 private _duration;

contracts/examples/SampleCrowdsale.sol

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import "../token/ERC20/ERC20Detailed.sol";
1212
* It is meant to be used in a crowdsale contract.
1313
*/
1414
contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
15-
constructor () public ERC20Detailed("Sample Crowdsale Token", "SCT", 18) {}
15+
constructor () public ERC20Detailed("Sample Crowdsale Token", "SCT", 18) {
16+
// solhint-disable-previous-line no-empty-blocks
17+
}
1618
}
1719

1820
/**
@@ -28,11 +30,6 @@ contract SampleCrowdsaleToken is ERC20Mintable, ERC20Detailed {
2830
* After adding multiple features it's good practice to run integration tests
2931
* to ensure that subcontracts works together as intended.
3032
*/
31-
// XXX There doesn't seem to be a way to split this line that keeps solium
32-
// happy. See:
33-
// https://github.com/duaraghav8/Solium/issues/205
34-
// --elopio - 2018-05-10
35-
// solium-disable-next-line max-len
3633
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
3734
constructor (
3835
uint256 openingTime,

contracts/introspection/ERC165.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import "./IERC165.sol";
88
* @dev Implements ERC165 using a lookup table.
99
*/
1010
contract ERC165 is IERC165 {
11-
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
11+
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
1212
/**
1313
* 0x01ffc9a7 ===
1414
* bytes4(keccak256('supportsInterface(bytes4)'))
@@ -24,7 +24,7 @@ contract ERC165 is IERC165 {
2424
* implement ERC165 itself
2525
*/
2626
constructor () internal {
27-
_registerInterface(_InterfaceId_ERC165);
27+
_registerInterface(_INTERFACE_ID_ERC165);
2828
}
2929

3030
/**

contracts/introspection/ERC165Checker.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ pragma solidity ^0.5.0;
77
*/
88
library ERC165Checker {
99
// As per the EIP-165 spec, no interface should ever match 0xffffffff
10-
bytes4 private constant _InterfaceId_Invalid = 0xffffffff;
10+
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
1111

12-
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
12+
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
1313
/**
1414
* 0x01ffc9a7 ===
1515
* bytes4(keccak256('supportsInterface(bytes4)'))
@@ -23,8 +23,8 @@ library ERC165Checker {
2323
function _supportsERC165(address account) internal view returns (bool) {
2424
// Any contract that implements ERC165 must explicitly indicate support of
2525
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
26-
return _supportsERC165Interface(account, _InterfaceId_ERC165) &&
27-
!_supportsERC165Interface(account, _InterfaceId_Invalid);
26+
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
27+
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
2828
}
2929

3030
/**
@@ -94,13 +94,13 @@ library ERC165Checker {
9494
* indicates support of the interface with identifier interfaceId, false otherwise
9595
*/
9696
function _callERC165SupportsInterface(address account, bytes4 interfaceId)
97-
private
98-
view
99-
returns (bool success, bool result)
97+
private
98+
view
99+
returns (bool success, bool result)
100100
{
101-
bytes memory encodedParams = abi.encodeWithSelector(_InterfaceId_ERC165,interfaceId);
101+
bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
102102

103-
// solium-disable-next-line security/no-inline-assembly
103+
// solhint-disable-next-line no-inline-assembly
104104
assembly {
105105
let encodedParams_data := add(0x20, encodedParams)
106106
let encodedParams_size := mload(encodedParams)

contracts/mocks/AllowanceCrowdsaleImpl.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ contract AllowanceCrowdsaleImpl is AllowanceCrowdsale {
88
public
99
Crowdsale(rate, wallet, token)
1010
AllowanceCrowdsale(tokenWallet)
11-
{}
11+
{
12+
// solhint-disable-previous-line no-empty-blocks
13+
}
1214
}

contracts/mocks/CappedCrowdsaleImpl.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ contract CappedCrowdsaleImpl is CappedCrowdsale {
88
public
99
Crowdsale(rate, wallet, token)
1010
CappedCrowdsale(cap)
11-
{}
11+
{
12+
// solhint-disable-previous-line no-empty-blocks
13+
}
1214
}

contracts/mocks/CapperRoleMock.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ contract CapperRoleMock is CapperRole {
88
}
99

1010
function onlyCapperMock() public view onlyCapper {
11+
// solhint-disable-previous-line no-empty-blocks
1112
}
1213

1314
// Causes a compilation error if super._removeCapper is not internal

contracts/mocks/CrowdsaleMock.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ pragma solidity ^0.5.0;
33
import "../crowdsale/Crowdsale.sol";
44

55
contract CrowdsaleMock is Crowdsale {
6-
constructor (uint256 rate, address payable wallet, IERC20 token) public Crowdsale(rate, wallet, token) {}
6+
constructor (uint256 rate, address payable wallet, IERC20 token) public Crowdsale(rate, wallet, token) {
7+
// solhint-disable-previous-line no-empty-blocks
8+
}
79
}

contracts/mocks/DetailedERC20Mock.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ import "../token/ERC20/ERC20.sol";
44
import "../token/ERC20/ERC20Detailed.sol";
55

66
contract ERC20DetailedMock is ERC20, ERC20Detailed {
7-
constructor (string memory name, string memory symbol, uint8 decimals) ERC20Detailed(name, symbol, decimals) public {}
7+
constructor (string memory name, string memory symbol, uint8 decimals)
8+
public
9+
ERC20Detailed(name, symbol, decimals)
10+
{
11+
// solhint-disable-previous-line no-empty-blocks
12+
}
813
}

contracts/mocks/ERC165/ERC165InterfacesSupported.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import "../../introspection/IERC165.sol";
44

55
/**
66
* https://github.com/ethereum/EIPs/blob/master/EIPS/eip-214.md#specification
7-
* > Any attempts to make state-changing operations inside an execution instance with STATIC set to true will instead throw an exception.
7+
* > Any attempts to make state-changing operations inside an execution instance with STATIC set to true will instead
8+
* throw an exception.
89
* > These operations include [...], LOG0, LOG1, LOG2, [...]
910
*
1011
* therefore, because this contract is staticcall'd we need to not emit events (which is how solidity-coverage works)
1112
* solidity-coverage ignores the /mocks folder, so we duplicate its implementation here to avoid instrumenting it
1213
*/
1314
contract SupportsInterfaceWithLookupMock is IERC165 {
14-
bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7;
15+
bytes4 public constant INTERFACE_ID_ERC165 = 0x01ffc9a7;
1516
/**
1617
* 0x01ffc9a7 ===
1718
* bytes4(keccak256('supportsInterface(bytes4)'))
@@ -27,7 +28,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 {
2728
* implement ERC165 itself
2829
*/
2930
constructor () public {
30-
_registerInterface(InterfaceId_ERC165);
31+
_registerInterface(INTERFACE_ID_ERC165);
3132
}
3233

3334
/**
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
pragma solidity ^0.5.0;
22

3-
contract ERC165NotSupported {}
3+
contract ERC165NotSupported {
4+
// solhint-disable-previous-line no-empty-blocks
5+
}

0 commit comments

Comments
 (0)