Steeltoe icon indicating copy to clipboard operation
Steeltoe copied to clipboard

Address Sonar rules related to lack of "CultureInfo" usage

Open bart-vmware opened this issue 3 years ago • 0 comments

Address existing violations of the following, related rules:

in the codebase and set severity to Warning in Steeltoe.Debug.ruleset and Steeltoe.Release.ruleset.

To find existing violations, enable the rule (see above) and rebuild src/Steeltoe.All.sln to make them appear in the Output window.

To address the violations, choose from the following on a case-by-case basis:

  • Always use ToUpper[Invariant] instead of ToLower, this matters in Turkey.
  • Always pass culture information. Decide whether the call should be culture-sensitive or not
    • Use the Invariant Culture to not depend on OS-level regional settings (date/time/decimal separators), typically used for import/export file formats, query languages, file paths etc.
    • Never use "en-US", this still takes OS-level settings into account: lots of SpeL tests fail even when running on English Windows with Dutch regional settings.
    • Use the Current Culture to take culture-specific rules into account, for example:
      • "Straße" and "Strasse" are equivalent in German
      • The number "1,234.56" is formatted as "1.234,56" in Dutch
  • ~Suppress the violation in code using #pragma warning disable/restore, preceded by a justification comment if not obvious~

Related to #949.

bart-vmware avatar Jul 28 '22 10:07 bart-vmware