solana-lints icon indicating copy to clipboard operation
solana-lints copied to clipboard

Lint 6: duplicate-mutable-accounts

Open oslfmt opened this issue 3 years ago • 5 comments

Quick and somewhat-dirty implementation of lint 6. Tests pass, but may need further work/clean-up when encountering >2 duplicate accounts.

oslfmt avatar Jul 12 '22 21:07 oslfmt

Completed upgrade so lint can effectively handle cases where number of identical accounts > 2. All tests pass except for secure. To make secure pass, the lint simply needs to also check for key-check constraints that are not specified within the anchor [#account] macro.

oslfmt avatar Jul 16 '22 15:07 oslfmt

@smoelius lint 6 is completely done as it stands. Only small thing that is bugging me (and this is personal preference) is that when there are no key checks at all (not using anchor macro constraints, nor alternate constraints such as in function bodies), then the lint will print messages related to the v2 lint I wrote, which doesn't have as nice messages. This is due to some of the logic of the program, and its fairly involved to change it than one might think.

Ideally, if no constraints are in the program at all, I would have liked for the lint to print the v1 messages, ie, the one that recommends adding the #[account] macro constraints, since this is best/recommended practice for anchor programs. I think this applies generally to all these lints, that we should recommend programs to do checks the anchor way, instead of some alternate method.

oslfmt avatar Jul 19 '22 20:07 oslfmt

also if there's too many commits, I can squash

oslfmt avatar Jul 19 '22 20:07 oslfmt

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

:white_check_mark: smoelius
:x: oslfmt
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Jul 21 '22 02:07 CLAassistant

@victor-wei126 Can you sign the CLA?

smoelius avatar Jul 21 '22 02:07 smoelius