Presence of Unused Variables

From WEB3 Vulnerapedia
Jump to navigation Jump to search

Presence of Unused Variables

Although it is allowed, it is best practice to avoid unused variables. Unused variables can lead to a few different problems:

  • Increase in computations (unnecessary gas consumption)
  • Indication of vulnerabilities or malformed data structures
  • Decreased code readability

It is highly recommended to remove all unused variables from a code base.

Sources

https://github.com/kadenzipfel/smart-contract-vulnerabilities/blob/master/vulnerabilities/unused-variables.md

https://swcregistry.io/docs/SWC-131

https://ethereum/solidity#718

https://ethereum/solidity#2563