-
Notifications
You must be signed in to change notification settings - Fork 73
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
Rule for List.length l = 1
and l.Length = 1
#543
Comments
@smoothdeveloper thanks for filing this bug. I just became recently a maintainer so take my PoV with a grain of salt (and don't assume I know the "inner philosophy" of FSharpLint in its entirety :) ). My suggestion to add List.isSingleton to FSharp.Core's List was, essentially, because without it: But if you have the time to write it, sure, please propose a PR, even if List.isSingleton is not included yet in FSharp.Core. Side-note: maybe a suggestion that is easier to be merged in the short-term is to actually propose a PR for FSharpx.Collections (in fact we did something similar recently and now FSharpLint suggests FSharpx.Collections in another rule), before it gets proposed/merged in FSharp.Core. |
Just my 2p: Adding the following to the
PS, a little bug in FSharpLint doesn't repeat the
An alternative would be to add |
Taking a discussion running on dotnet/fsharp#12998 (comment) related to replacing
list.Length = 1
with cheaper construct.@knocte I don't know the inner philosophy of FSharpLint, if I had to split it the way your question suggests:
List.isSingleton
here), what matters is, helps the developer to save CPU cycles, more than how the code is changedFirst one is like mechanic empathy, the second one is developer empathy, and FSharpLint is probably helping setting good balance where it makes most sense (those easy cases).
I'd say considering the discussion stems from an internal compiler member for now, chance of the fix making it to FSharp.Core soon are not the most favorable, for delaying having the check, for those looking to refactor the code already (they can introduce type extension for it manually), if the check can be added without a lot of work.
We can suggest
= []
... edit. not! we can only suggest to have the module extension, which kind of answers the question.I'd just like to have this warning or the FCS analyser thing, to be running mostly, and fixing the code is exercise left to the reader.
cc: @auduchinok
The text was updated successfully, but these errors were encountered: