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
Fix FP S2871 (no-alphabetical-sort
): Add exception for string arrays
#4531
Comments
@ilia-kebets-sonarsource, wouldn't adding this exception contradict the documentation and the initial purpose of the rule? I quote the documentation:
This case would not trigger the rule anymore if we add the exception. Is it desirable? Should I update the documentation accordingly? |
|
Currently, the message is the same across all cases (arrays of strings, heterogeneous arrays...): "Provide a compare function to avoid sorting elements alphabetically." Only the suggestions differ. For arrays of strings, the suggestion is "Add a comparator function to sort in ascending language-sensitive order." For arrays of strings, I propose changing the emitted message to something like "Provide a compare function that depends on string.localeCompare, to reliably sort elements alphabetically." or "Provide a compare function that reliably sorts elements alphabetically." - ideas more than welcome. The suggestion already looks good to me. |
Do not raise the issue when the array is an array of strings:
The text was updated successfully, but these errors were encountered: