Open brian-reichle opened 3 years ago
If the result of string.ToUpper or string.ToLower is simply used in a comparison, then that's a pretty good indication that a case-insensitive comparison should be used instead.
string.ToUpper
string.ToLower
foo.ToUpper() == "FOO" "foo" == foo.ToLower(CultureInfo.InvariantCulture) string.Equals(foo.ToUpper(CultureInfo.InvarintCulture), "FOO") foo.ToUpper().CompareTo("FOO") string.Compare(foo.ToUpper(), "FOO", StringComparison.Ordinal)
Should become:
foo.Equals("FOO", StringComparison.CurrentCultureIgnoreCase) "foo".Equals(foo, StringComparison.InvariantCultureIgnoreCase) string.Equals(foo, "FOO", StringComparison.InvarintCultureIgnoreCase) string.Compare(foo, "FOO", StringComparison.CurrentCultureIgnoreCase) string.Compare(foo "FOO", StringComparison.OrdinalIgnoreCase)
Should probably report things like the following as errors on the basis that they well never match:
foo.ToUpper(CultureInfo.InvariantCulture) == "Foo" foo.ToLower(CultureInfo.InvariantCulture) == "Foo"
Should the bottom section be one of those "replace with false" code-fixes? :laughing:
That's what I was thinking, or rather "replace with false and simplify".
If the result of
string.ToUpper
orstring.ToLower
is simply used in a comparison, then that's a pretty good indication that a case-insensitive comparison should be used instead.Should become:
Should probably report things like the following as errors on the basis that they well never match: