Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant require statements #1409

Merged
merged 3 commits into from
Nov 2, 2018

Conversation

BrendanChou
Copy link
Contributor

@BrendanChou BrendanChou commented Oct 11, 2018

Now that SafeMath uses require, the require statements are redundant. They were also previously inconsistent because they were only included in some functions, but not others

Now that SafeMath uses require, the require statements are redundant. They were also previously inconsistent because they were only included in some functions, but not others
@nventuro nventuro self-assigned this Oct 12, 2018
@nventuro nventuro added kind:improvement contracts Smart contract code. labels Oct 12, 2018
@nventuro
Copy link
Contributor

I've been thinking about this one for the last couple days. The good thing about those requires is that solidity-coverage will detect if the revert condition is never triggered, forcing us to write comprehensive tests that expose what can and cannot be done. Once that check is delegated to SafeMath, we would have no way of knowing (other than manually checking) if all cases have been considered.

This is of course not a great reason to keep them, specially considering we already have coverage for them, and they make the contracts more expensive for no reason, but wanted to get some thoughts on the matter. @cgewecke is there some way we could improve solidity-coverage regarding this?

@BrendanChou
Copy link
Contributor Author

In general, I think relying on "line coverage" isn't the best way to make sure that every edge case is covered, and the tests will just have to be written in such a way that we are confident that there is proper test coverage rather than adding lines to solidity and making sure that require statements are hit both as true and false

@nventuro
Copy link
Contributor

nventuro commented Nov 2, 2018

Fair enough, I'm fine with merging this. Thanks a lot @BrendanChou! I think there are some more scattered examples of this throughout the codebase, so we should also take care of those.

@nventuro nventuro merged commit 6363a77 into OpenZeppelin:master Nov 2, 2018
@BrendanChou BrendanChou deleted the patch-1 branch November 7, 2018 00:26
@k06a
Copy link
Contributor

k06a commented Nov 16, 2018

Amazing!

vittominacori added a commit to vittominacori/zeppelin-solidity that referenced this pull request Nov 21, 2018
…lidity into feature/token-recover

* 'master' of https://github.com/vittominacori/zeppelin-solidity: (98 commits)
  Renamed roles private variables to adhere to code style. (OpenZeppelin#1507)
  Remove extraneous quantity check, fixes OpenZeppelin#1454 (OpenZeppelin#1455)
  Remove redundant require statements (OpenZeppelin#1409)
  Add the step to delete the build dir to the RELEASE notes (OpenZeppelin#1467)
  add an address typecast to this per issue OpenZeppelin#1457 (OpenZeppelin#1471)
  add improvement in simpletoken example OpenZeppelin#1458 (OpenZeppelin#1473)
  SafeMath Test Coverage Improved (OpenZeppelin#1477)
  The beneficiary parameter of claimRefund is replaced with refundee (OpenZeppelin#1481)
  fix ERC20.sol#L174 and ERC20.sol#L187 should be casted to an address type. (OpenZeppelin#1470)
  Fix/add comment erc721 burnable OpenZeppelin#1464 (OpenZeppelin#1469)
  Release v2.0.0
  Release candidate v2.0.0-rc.4
  Improved some ERC721 internal shenanigans (OpenZeppelin#1450)
  Add warning about trading tokens before refundable crowdsale goal is met (OpenZeppelin#1452)
  Crowdsale.buyTokens is now nonReentrant. (OpenZeppelin#1438)
  InitialRate must be strictly larger than finalRate. (OpenZeppelin#1441)
  Fixed how allowance crowdsale checks remaining tokens. (OpenZeppelin#1449)
  Deleted unnecessary import. (OpenZeppelin#1437)
  Made SampleCrowdsale a bit clearer. (OpenZeppelin#1448)
  Now setting the finalized flag before doing finalization to prevent possbile reentrancy issues. (OpenZeppelin#1447)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contracts Smart contract code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants