oppiliappan / statix

lints and suggestions for the nix programming language
https://git.peppe.rs/languages/statix/about
MIT License
552 stars 21 forks source link

Deletes comments within empty let in #43

Closed SuperSandro2000 closed 2 years ago

SuperSandro2000 commented 2 years ago

While debugging a package in nixpkgs I noticed the following oddity: when you format a file which has only comments in the let in, all comments get deleted. Since the comments can be actual code I don't think that is intended.

Before:

_:

let
# those = {};
# are  = {};
# comments = {};
in {}

after:

_:

{}

statix 0.5.4

oppiliappan commented 2 years ago

i think the preferred behavior would be to not raise the lint if comments are present?

SuperSandro2000 commented 2 years ago

It should probably raise that still since the let in is unused but this is probably not auto fixable or should move the comment outside the let in.

oppiliappan commented 2 years ago

understood, just pushed v0.5.6 for this issue. the behaviour is as follows:

currently there is no way for the user to accept/reject fixes interactively, but ideally, that would be nice for this case.