-
Notifications
You must be signed in to change notification settings - Fork 128
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
no-empty-blocks false positives in inherited constructor #264
Comments
Thanks for reporting, I'll be investigating this |
@duaraghav8 I just discovered another false-positive case: empty contract body in an inherited contract. An example (simplified from my real-world use case): I have an abstract contract inheriting an abstract mixin. I then make a concrete contract just by inheriting a concrete mixin contract. The contract body is empty, but still required, while Example code: contract AbstractMixin {
function mixinFn() internal pure returns (uint256);
}
contract AbstractTest is AbstractMixin {
function test() external pure returns (uint256) { return mixinFn(); }
}
contract Mixin1 {
function mixinFn() internal pure returns (uint256) { return 1; }
}
contract Test1 is AbstractTest, Mixin1 {} |
Agreed, I'll be adding inheritance as an exception to this rule. |
Behaviour of this rule for constructors after fix: If a base contract is called eg- contract Foo {}
contract Bar is Foo {
// This cons. will not be flagged
constructor() Foo() {}
}
contract Lorem {
// This cons. WILL be flagged
constructor() public {}
}
contract Ipsum is Foo {
// This cons. WILL be flagged
constructor() public {}
}
contract Derived1 is Base(7) {
// This cons. WILL be flagged
constructor() public {}
} As for the case of contract, I'm still not sure I fully understand the thing, I'll have to read up on mixins, will update here then. |
The issue you originally filed has been fixed in The latest release is available on both |
Thanks! |
This also shows up for contracts with an |
@emilbayes can you point me to the docs on |
@duaraghav8 https://solidity.readthedocs.io/en/v0.5.12/contracts.html#constructor
Edit: wrong link |
Description
In an inherited contract, the constructor often just calls the base constructor, and its block is empty. This should be an exception from the
no-empty-block
rule, but now it causes awarning Code contains empty block
.Steps to reproduce
The command you used to lint:
npx solium --file test.sol
The solidity code over which you ran the linter
Copied from the official example.
.soliumrc.json
file.soliumignore
:node_modules
Expected behavior
The example constructor should not cause linter warnings.
Operating System
Linux
Linter version
1.2.4
The text was updated successfully, but these errors were encountered: