-
Notifications
You must be signed in to change notification settings - Fork 73
Add DisallowShadowing rule #676
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
base: master
Are you sure you want to change the base?
Add DisallowShadowing rule #676
Conversation
d25dadd to
f349def
Compare
|
@webwarrior-ws please add a test for shadowing for variables that start with underscore: in this case we don't want the rule to flag them. |
Added new commit with test and changes to the rule code. |
|
@webwarrior-ws let's rebase this again sorry. |
1fb6cc1 to
29b6c28
Compare
Nevermind, I just did it myself. However, I didn't manage to fix the build entirely so please continue adding commits here. Thanks |
ac41076 to
a52ab0c
Compare
|
Not sure the rule is working well, it seems to be flagging as a violation when two functions have parameters with the same name (look at my last WIP commit that I just pushed). |
I've noticed that too and added a test case for it. |
3a608c6 to
823cbe1
Compare
9226ca3 to
4a7b5ef
Compare
6afdf6b to
9a54685
Compare
e8e7af9 to
4052819
Compare
| | SynSimplePat.Attrib(pat, _, _) | ||
| | SynSimplePat.Typed(pat, _, _) -> | ||
| extractIdentifier pat | ||
| [<TailCall>] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@webwarrior-ws unrelated to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(take in account this is the commit to fix violations)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw does this mean that this is a false-negative that should have been fixed in PR819?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw does this mean that this is a false-negative that should have been fixed in PR819?
ah no, i just realised that this is in a new file that this PR is introducing, so what happens is that this change is in the wrong commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it in the wrong commit? It's in the "fix selfCheck" commit.
d823885 to
4f419dd
Compare
Added DisallowShadowing rule (no implementation yet). Added tests for it.
Implemented DisallowShadowing rule, making previously added tests pass. Fixes fsprojects#112
In DisallowShadowing rule, ignore variables that start with underscore (`_`). Added test for this case.
Co-authored-by: webwarrior-ws <reg@webwarrior.ws>
That makes sure that there is no false positive when different non-nested functions have the same parameter name.
Utilities.rangeContainsOtherRange only took line numbers into account, changed it to compare both line and column numbers.
That makes sure that there is no false positive for the same identifier in match clause used multiple times that doesn't shadow another identifier.
In match expressions.
That makes sure that there is no false positive for identifiers used as arguments to active pattern.
In match expressions with active pattern.
|
@webwarrior-ws let's rebase |
4f419dd to
72fbc93
Compare
4b355b0 to
dd6f099
Compare
Add DisallowShadowing rule and tests for it.
Fixes #112