Skip to content
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

Evaluate custom ink! lints using Dylint #281

Closed
2 tasks
cmichi opened this issue May 26, 2021 · 2 comments · Fixed by #431
Closed
2 tasks

Evaluate custom ink! lints using Dylint #281

cmichi opened this issue May 26, 2021 · 2 comments · Fixed by #431
Labels
enhancement New feature or request

Comments

@cmichi
Copy link
Collaborator

cmichi commented May 26, 2021

This blog post describes how to add project-specific lints to clippy using the Dylint crate. We should evaluate if it's possible to use this crate for implementing custom ink! lints.

A scenario that comes to my mind is the usage of accidental nested lazy data structures. For example, our collections in ink_storage are lazy anyway. So e.g. Lazy<Vec<u32>> doesn't provide additional benefits, but instead only adds computation overhead. It should be possible to access this type information using LateLintPass("[…] the LateLintPass has access to type information while the EarlyLintPass doesn't", source).

ToDo

  • Make cargo contract run a custom lint before each build/check.
  • The lint should output a warning (error?) if X in Lazy<X> is from ink_storage::collections.
@Robbepop
Copy link
Contributor

A scenario that comes to my mind is the usage of accidental nested lazy data structures. For example, our collections in ink_storage are lazy anyway. So e.g. Lazy<Vec> doesn't provide additional benefits, but instead only adds computation overhead. It should be possible to access this type information using LateLintPass("[…] the LateLintPass has access to type information while the EarlyLintPass doesn't", source).

Sounds like a really good prototype in order to see if the approach works for our use case.

@HCastano
Copy link
Contributor

There are two existing Clippy lints which could come in handy as references for the implementation of this lint:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants