-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Cleanup CodeFactor issues with null comparisions #6949
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
Cleanup CodeFactor issues with null comparisions #6949
Conversation
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.
this one is out of place. it should go after DeserializingTypeConverter.RehydrationFlags.MissingPropertyOk)
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.
This is single manual change I did :-)
The commit is replaced.
Also removed extra curves
|
People use If this CodeFactor warning didn't find a bug, I'd disable the warning, it doesn't feel like it's worth the risk of so many changes via regex without much higher confidence the tests cover all of these changes. |
|
If you remember a year ago, I offered to fix style in tests. Response team was negative - it is better to spend your time on more useful things. It was a convincing position. Then we continued to receive many-many comments on the style of tests each PR. Finally everyone ran out of patience and we fixed our tests. |
|
I sampled the report from CodeFactor when it was first enabled and wasn't impressed. Maybe after you refine the rules it will show some value, but I'm still skeptical. As one data point for my skepticism - you touched 187 files in this PR, but CodeFactor claims there are 119 issues fixed and only 99 of the issues fixed are of the So if you found 88 or more places to fix that the tool didn't, humans will continue to find similar nits that the tool won't. Contributors will have one additional barrier to contributing in addition to the human nitpickers. If the nitpicking isn't adding value, you could try asking those making the comments to try less nitpicking. |
|
When I joined the project, the first three months I was amazed each time I got different types of style comments from different people. Why team did it? Obviously to get good code. What changed this time? Nothing. We will not be able to change our behavior if we do not take any steps.
On CodeFactor site it is mentioned that they use their config and some other analysis methods - so we can get "weird" and "amazing" results. After we merge our config we can investigate problems if we find them. |
|
In this specific case - I find it reasonable to adopt the exact opposite of what CodeFactor suggests, but I think it is even more reasonable to disable the warning and move on to more important issues. Sometimes word order matters, sometimes the order of words doesn't matter. Either way, we understand the message clearly. If code reviewers are complaining about this exact issue - they too should find more valuable things to complain about. |
|
My last comment on this specific issue - CoreFx is roughly as inconsistent as PowerShell, with about 6% of the comparisons using With some irony, if you fix this, we'd be less like CoreFx. :) |
I believe that this difference comes from the fact that some code is under |
|
I think this rule should remain enabled and this change can be closed if the team does not want it. /cc @SteveL-MSFT @daxian-dbw |
|
I scrolled through the changes and don't see any issues with the change itself. So the risk seems low. As for whether we want to make this change, I think readability is slightly better with Since @iSazonov has already done the work, risk seems low, and (personally) readability is better. I would be for taking this change. However, I think it's a decision the @PowerShell/powershell-maintainers should make. |
|
Resolve merge conflicts. |
|
restarted Linux CI, I'll be OOF for a couple of days. |
|
@TravisEz13 @adityapatwardhan and I discussed this offline and we agree to take this PR for the same reasons as @SteveL-MSFT mentioned above. But in general, we prefer less changes per PR for style related changes:
I will soon go through this PR and merge it. |
I suggest to apply this rule only to code. We have tons style issues for doc comments - I think we could change more files per PR in the case without risk. Seems also the rule assumes that we could fix style issues by file, by module, by cmdlet set (ex., web cmdlets), by provider and so on. Does this conclusion imply that our policy is changed and we want and accept style changes? |
|
@iSazonov Doc comments issues can be an exception, because of the super low risk. It's not a rule, but a flexible guideline for us maintainers to consider (you can read the tone -- The main reason that we don't want massive changes in a PR is the time cost to review -- it will be easy for the PR to end up with no approval since no one wants to spend the time reviewing all the changes. This will, in turn, hurt the author's feeling and discourage the author's further contribution, because if the author really meant to fix those style issues, he/she must have put a lot effort/time into it. So we want to set some guidelines to help prevent a contributor from getting in that situation. |
We accept PRs that are purely for style changes (we have to if we want to make CodeFactor useful). Such a PR should be reviewable, and that's why we proposed the flexible guideline. But this should be temporary -- once the existing style issues reported by CodeFactor are fixed, we won't accept PR with pure style changes. |
daxian-dbw
left a comment
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.
Went through the changes. LGTM.
|
@daxian-dbw Thanks for code review and clarifications! |
PR Summary
Please fast review to avoid merge conflicts because of many files changed.
Please review commit by commit - every commit contains only single kind of change so you can do very fast review.
This corrects about 1% of the CodeFactor issues.
The PR replace
null != varwithvar != nullandnull == varwithvar == nullAll changes is made in VS Code with Regex patterns - one pattern by commit:
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests