Rule to recommend if-else construct instead of match clause#822
Rule to recommend if-else construct instead of match clause#822webwarrior-ws wants to merge 7 commits intofsprojects:masterfrom
Conversation
|
From #586:
|
| type Baz = | ||
| | Bar | ||
|
|
||
| match foo with |
There was a problem hiding this comment.
@webwarrior-ws this cannot be written as if foo = Baz.Bar?
There was a problem hiding this comment.
Actually it can. Though in this situation pattern matching seems more natural choice.
So should I remove this case from exceptions to the rule?
There was a problem hiding this comment.
yes let's remove it because I want to see what's the impact on SelfCheck; keep your change around in case we put it back
|
|
||
| match foo with | ||
| | Bar -> () | ||
| | _ -> () |
There was a problem hiding this comment.
@webwarrior-ws give me an example of a type that foo could have that would fall under this _ case?
|
Other 2 testcases to add here are: and which both should trigger violations. |
b816299 to
d703c99
Compare
Actually, latter should only trigger violation if notNullFoo is unused (if it's used, it might prevent a race condition which would be present when using if-else block). |
Unused variable is detected by compiler. So perhaps it should not trigger violation? |
2d457dc to
0ae8f45
Compare
e5430e5 to
c5a335a
Compare
|
@webwarrior-ws let's rebase this when you have time |
11ac9e8 to
4aa565b
Compare
Rebased. |
655a661 to
90ea90e
Compare
130b606 to
9e9239a
Compare
It improves code readability. Fixes: fsprojects#545 Co-authored-by: webwarrior-ws <reg@webwarrior.ws>
36ea86e to
d55bdd2
Compare
For cases with `when` clause.
Co-authored-by: webwarrior-ws <reg@webwarrior.ws>
For (null, wildcard) case.
9d6fd87 to
cc94e8d
Compare
It improves code readability.
Fixes: #545
Supersedes #588