-
Notifications
You must be signed in to change notification settings - Fork 9
Another false positive #7
Comments
Thanks for reporting, that's a really interesting one. I'm not sure about your proposition however. Most of the times, having some code between the two statements does not lead to consequences that your snippet aims to show. On the other hand, building a reliable detector for cases like yours sounds too ambitious for a small pet project like If I don't come up with some feasible way of detecting cases where the in-between code makes using short syntax impossible, I'm afraid that I can't offer you anything but an optional setting in a future minor release, which would enable the behaviour you propose. |
Do you want this linter to prefer false positives or false negatives? Personally, I think false negatives are better for stylistic linters like this one – it is better to keep code slightly inconsistent than wrong or with a lot of Also, not sure I agree with "most of the times" – I would say if there is some code between assignment and |
Do you have a different example that would reflect this clearly? I do believe they exist, but I'm suspect the example provided would be clearer following the When we're dealing with
It's also typical that
I suspect in a lot of cases, that could be
|
Also having false positive when using a variable inside the embedded struct. Here's an example:
This yields
However it's clear that I set referrer in the embedded struct. Without embedding there is no false positive though. |
That will hold |
same with @sashayakovtseva code |
In general, I think ifshort should skip cases when there is some code between assignment and
if
The text was updated successfully, but these errors were encountered: