solidity
solidity copied to clipboard
Warning about unused imports
Currently, the compiler issues a warning for an unused function parameter. I think it would be a good idea to do the same for unused imports in order to improve the quality and cleanliness of the code.
Example
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;
/// @dev This import is unused. The compiler should issue a warning.
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract MockContract {
function hashFunction() external pure returns (bytes32) {
return keccak256("Hello World");
}
}
libtasn1-6/stable 4.16.0-2+deb11u1 amd64 [upgradable from: 4.16.0-2]
4.26.0.3
I agree, this would be a nice thing to have. We should discuss this on one of the upcoming design calls and see if we have consensus in the team to go forward with it.
We discussed this and agreed that it would be nice to have, though very low priority. We'd be open to contributions. The nice thing about it is that it's very clear in terms of what the end result should be. In terms of implementation it might not be that easy though, and we really would not like it to just be hacked into the analyzer so anyone working on it should first drop on one of the team calls and discuss the details with us first.
Would also be nice to have a warning for unused modifiers and custom errors.
This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.
Don't close this issue.
I'd also be in favor of both unused imports and particularly custom errors these are later added to the interfaceId in some way
This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.
Don't close this issue as it's still relevant.
This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.
Don't close this issue as it's still relevant.