-
Notifications
You must be signed in to change notification settings - Fork 11
FL0002
David Mitchell edited this page Mar 14, 2019
·
5 revisions
Many methods that operate on strings default to using the current culture, which is not always correct. If a method has an overload that takes a StringComparison
parameter, that overload should be invoked with an explicit StringComparison
specified.
if (text.StartsWith("http:")) // BAD
if (text.StartsWith("http:", StringComparison.Ordinal)) // GOOD
It is also acceptable to call an overloads that take a CultureInfo
parameter.
Add a StringComparison.Ordinal
argument.
The suggested fix always uses Ordinal comparison; in some cases, culture-sensitive comparison would be better. The fix simply appends the StringComparsion
argument to the current argument list, instead of finding the "best" overload to call and mapping the current arguments to it.
-
FL0006 Optional
IComparer<string>
arguments must always be specified