-
Notifications
You must be signed in to change notification settings - Fork 29
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 S6575: Use TimeZoneInfo.FindSystemTimeZoneById instead of TimezoneConverter #1729
Conversation
76a73b8
to
cd0bb60
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.
Please take a look at the comment I left, it might be that the rule will not be able to cover all cases.
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.
Like the rspec a lot, I left a few minor comments, and please address the formatting and common parts sharing between C# and VB.NET
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! Please fix the variable name on the snippet
b072c69
to
820f1a8
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.
Round 2.
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.
One last round.
rules/S6575/how.adoc
Outdated
@@ -0,0 +1,4 @@ | |||
== How to fix it | |||
|
|||
There's no need to translate manually between time zones; it is enough `TimeZoneInfo.FindSystemTimeZoneById(string timezone)`, where the timezone can be IANA or Windows format. |
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.
There's no need to translate manually between time zones; it is enough `TimeZoneInfo.FindSystemTimeZoneById(string timezone)`, where the timezone can be IANA or Windows format. | |
There's no need to translate manually between time zones; it is enough to call `TimeZoneInfo.FindSystemTimeZoneById(string timezone)`, where the timezone can be IANA or Windows format. |
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 "to call" should go before the method name, no?
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 approved, please fix the one last remaining issue.
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.
one suggested text change
rules/S6575/why-dotnet.adoc
Outdated
== Why is this an issue? | ||
|
||
The method `TimeZoneInfo.FindSystemTimeZoneById(string timezone)` can get both IANA and Windows timezones as input and automatically convert one to the other if the requested time zone is not found on the system. | ||
This means that one does not have to handle the conversion and make the code more complicated and thus more difficult to maintain. |
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'd change this to: "Because one does not need to handle the conversion the code will be less complex and easier to maintain."
SonarQube Quality Gate for 'rspec-frontend' |
SonarQube Quality Gate for 'rspec-tools' |
8918c85
to
b2b202f
Compare
SonarQube Quality Gate for 'rspec-tools' |
SonarQube Quality Gate for 'rspec-frontend' |
SonarQube Quality Gate for 'rspec-tools' |
SonarQube Quality Gate for 'rspec-frontend' |
c9cbeb3
to
24cfdba
Compare
SonarQube Quality Gate for 'rspec-tools' |
SonarQube Quality Gate for 'rspec-frontend' |
You can preview this rule here (updated a few minutes after each push).
This rule should raise when the project targets .net6 and TimeZoneConverter methods for IANA and Windows Timezones are used.
IanaToWindows
WindowsToIana
TryIanaToWindows
TryWindowsToIana
TimeZoneConverter also covers Rails Timezones - we should not raise there as imeZoneInfo.FindSystemTimeZoneById does not cover these.