-
Notifications
You must be signed in to change notification settings - Fork 30
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
Create rule S6580: Use a format provider when parsing date and time #1737
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.
Left a few suggestions.
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.
Second round
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.
Few nitpicks, looks good!
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.
Almost there! I left a couple of comments
rules/S6580/csharp/rule.adoc
Outdated
[source,csharp,diff-id=1,diff-type=noncompliant] | ||
---- | ||
var dateTimeString = "4/12/2023 4:05:48 PM"; // This is an en-US format string - 12 of April 2023 | ||
var dateTimeObject = DateTime.Parse(dateTimeString); // In a machine with "CultureInfo.CurrentCulture" en-150 (English Europe), this is parsed as 4th of December |
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.
I would somehow move this comment out from this line as it applies also for the other two lines where there is a runtime error.
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.
I added part of this comment next to the Runtime error
to be clearer why the runtime error happens.
In this line, I would leave this comment - as we don't have a runtime error but we parse one date and we get another one.
I made it more explicit though.
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.
Please apply the same stuff to the vb.net code examples 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.
last round
be8f285
to
2afa140
Compare
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!
SonarQube Quality Gate for 'rspec-frontend' |
de9c48d
to
55b9985
Compare
SonarQube Quality Gate for 'rspec-frontend' |
SonarQube Quality Gate for 'rspec-tools' |
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!
You can preview this rule here (updated a few minutes after each push).
Raise an issue for the Parse methods listed in the description if an IFormatProvider is not provided.