Suppose I have an interface:
pragma solidity 0.7.6;
interface Foo {
function foo() public view returns(bool);
}
And a simplistic implementation like a mock:
contract Bar is Foo {
function foo() public view returns(bool} {
this; // silence state mutability warning
return true;
}
}
This part:
this;
... sort of works. See here: Function overriding versus Solidity Compiler Warning: Function state mutability can be restricted to pure
It seems clean enough with truffle compile and hardhat compile but solidity-coverage still complains about it:
state mutability can be restricted to pure
Sure, but this is a false positive. We don't want to change any code. The perfectionist in me doesn't want to see alarming warnings where no issue exists.
Is there a better way to silence the warning?
Thanks :-)
pure. – Lauri Peltonen Apr 07 '21 at 06:29view... this implementation has no need to read the state, but other implementations do. – Rob Hitchens Apr 07 '21 at 15:02