onflow/cadence-tools

[Lint] Recommend minimal type

Opened this issue · 0 comments

Feature Request

Programs should always use the most specific type possible, following the principle of least privilege.
Types should always be as specific (restrictive) as possible, especially for resource-types.
This can be accomplished by using restricted types and interfaces.

An analyzer could look at how a variable/parameter is used, then find the minimal set of interfaces that is needed to allow the uses, and finally recommend the minimal restricted type.

For example, if only the balance field of a FT Vault is read, the type could just be &Vault{Balance} instead of &Vault