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

Add rule for detecting redundant fallback function #181

Open
fvictorio opened this issue Jan 30, 2020 · 0 comments
Open

Add rule for detecting redundant fallback function #181

fvictorio opened this issue Jan 30, 2020 · 0 comments
Labels

Comments

@fvictorio
Copy link
Contributor

Adding a fallback function that just reverts:

function () external payable {
  revert();
}

is the same as not adding it (and maybe the bytecode is unnecessarily larger? I don't know if the compiler is smart enough to detect this).

We could have a rule for detecting this. The rule should check if the fallback function has only one statement and if that statement is a call to revert.

The only potential issue I see is if you add a revert function to your contract and you want that function to be called in the fallback function. This would trigger a false positive. We could check if there's a function revert in the contract, but the function could be inherited from another contract. So I wouldn't bother: if someone is doing this, then they can just disable the rule.

Possible names:

  • no-redundant-fallback
  • no-unnecessary-fallback
  • dude-or-gal-check-the-docs-you-can-drop-that-code
  • Other?

cc @patitonar @fernandomg @pablofullana

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant