-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add allow-cuddle-assignment-not-used-in-block
to allow cuddle assignment not used in block
#141
base: master
Are you sure you want to change the base?
Conversation
Hi, thanks for the PR! I guess this aims to solve the comments from #24 (like #24 (comment))? Those comments refers to I wonder if we should add this as an opt-out for all blocks as described in #24 (comment) and not only Or, alternatively, change the configuration to be a list that accepts the different kind of blocks you want to opt out, f.ex. If we add this and want to remove it later it would be a breaking change and require a major version bump so I need to think about what makes most sense here. Please feel free to add you thoughts if you have any! |
Hi, thanks for your response. I will update my code as soon as possible. |
No rush! And I've been thinking about this and I think that either you want this rule or not so I think a single opt-out (bool) to disable it for all blocks makes most sense. Using strings to represent will be tricky because we would have something like "type_switch" in that list. So just renaming the option to something like |
Hi dear Simon, I hope this message finds you well. I just wanted to let you know that I revised my code based on your suggestion. Could you please provide feedback on this pull request . |
* Add backlinks to all configurables * Add tests for all configurable blocks * Move early return last so we report other violations to avoid false positives * Rename flag to match internal value and making it clear, `allow-cuddled-assignments-and-blocks`. * Fix faulty flag override (`flag` vs. `flags`)
allow-cuddled-assignments-and-blocks
to allow cuddle assignments not used in block
Now that I read the title of this PR I realized it's a bit confusing. This change is to allow the rules of unused assignments and blocks, not to allow an arbitrary amount of assignments. Those are two different rules in I added some negative tests to ensure this is the case. I think if we want to allow both we should add a new flag, something like To clarify this I want to rename this flag/option to |
allow-cuddled-assignments-and-blocks
to allow cuddle assignments not used in blockallow-cuddle-assignment-not-used-in-block
to allow cuddle assignment not used in block
@zahraKeshtkar Thank you so much for this! I'm ready to merge this but just want to hear your thoughts around calling it |
Thank you for taking the time to provide your feedback and suggestions! I'm sorry, but I didn't quite understand your comment. Are you suggesting that we change the name of the "allow-cuddle-assignment-not-used-in-block." and ensure that this naming convention is followed throughout the entire project? Once again, thank you for your valuable input. |
Sorry for the confusion. Mostly just wanted a better name for the flag since with this change we're not allowing multiple assignments even with this flag enabled and we're not allowing cuddling multiple blocks.
x := 1
y := 2
if true {} x := 1
if true {}
if false {} But we support none of them with this change, only these: x := 1
y := 2
if true {} x := 1
if true {}
if false {} So to clarify that it's a single assignment with a single block even though it's not used in the expression I thought |
I completely understand your point, but I have a question. What is your opinion on supporting all of the above? I am willing to modify the code to accommodate all of them, especially this one, as it is necessary for my project.
|
TL;DR: For version 4 we need a new flag to disable the check for multiple assignments before any block (all the Does this mean that merging this PR in the current state won't solve your issues and would only make sense if we add this new other flag? I don't know really. Both this PR and your last suggestion is straight up against the original reason behind Either way, your last suggestion is a different rule violation, it's the I've been thinking about a v5 and what that could imply several times but never really landed in anything and therefore haven't continued on it. One thing that I do think would be good however would be to not separate all the rules but rather only have two violations
We could then just accept a list and call each rule something, preferable something easy to understand, where you just enable them, f.ex. allow-missing-empty-line:
- if
- switch
- assign
allow-extra-empy-line:
- block-start
- block-end
- multiple-assignments-before-if In #89 we briefly touched on the subject to be able to disable any rule. |
It'd be great if we could provide support for everyone, but if that's not possible, we'll proceed with this PR. I concur with you that the current name is perplexing. How about changing it to this |
Hey, sorry for 🐌 Yeah I also think it's nice to have it configurable, I just don't like the way the code is currently growing it its current state with all the flags. Having a way to disable everything isn't unthinkable of for me at some point. All other flags uses the I'm happy to merge this as-is if you think it's fine! |
No description provided.