- Notifications
You must be signed in to change notification settings - Fork 8.1k
Cleanup CodeFactor issues with empty strings#6950
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 empty strings #6950
Uh oh!
There was an error while loading. Please reload this page.
Conversation
iSazonov commented May 28, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
markekraus 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.
LGTM assuming tests pass
iSazonov commented May 28, 2018
@markekraus Many thanks for fast review! |
dca7c3f to 84ea832Comparelzybkr commented May 29, 2018
I don't see the point. Why not just disable the warning and skip the code churn? |
iSazonov commented May 30, 2018
It is readability issue. If we use advanced editor with code highlighting we haven't problems to see "". If we use a simple editor the string.Empty visibility is much better. |
lzybkr commented May 30, 2018
I find |
BrucePay 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.
Overall the results look good. All the changes seem fine.
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.
Could migrate all of the ", " strings into a constant.
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.
Constant or static?
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.
Is there any reason it shouldn't be constant?
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.
We already have a lot of static variables for such strings.
I found 4487 hits in 581 file for ", ". So static may be useful.
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.
As long as we don't need to change the string, I prefer constant. But that should be in a separate 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.
If this is an autogen'ed file should you be changing it or the generator?
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.
The files is not regenerated and already was changed manually. Seems we should rename the files and remove "autogen" from file names.
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.
And remove the comments saying "this is an autogen'ed file, don't edit"
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.
Tracking issue #6974
iSazonov commented Jun 6, 2018
@SteveL-MSFT Can we merge? |
dantraMSFT commented Jun 8, 2018
@iSazonov What does indicate as the reasoning for this change? Is this a readability or programmatic warning? My understanding of "" is that it is interned and you will have one instance per assembly. In all other regards, String.Empty is synonymous with "". |
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 should be reverted.
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.
Good catch!
Fixed.
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.
missing replacing an instance of ""
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.
Fixed.
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.
Here too.
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.
Fixed.
daxian-dbw commented Jun 8, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@dantraMSFT I think the purpose is to enable the style checking about empty string (favor @iSazonov Thanks for spending efforts on driving the style consistency. I ran I quickly go through the changes and didn't notice any replacements in PowerShell scripts in |
iSazonov commented Jun 9, 2018
@dantraMSFT The PR has a purpose to turn CodeFactor into a more useful tool. Currently we see over 100000 issues most of which are style issues. |
18ed825 to 3ef9ef0Compare3ef9ef0 to dec9f0cCompareiSazonov commented Jun 9, 2018 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@daxian-dbw I re-check - no scripts was changed. Rebased to remove PSReadline. |
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 "" with string.Empty.
All 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