dart-lang / linter

Linter for Dart.
https://dart.dev/tools/linter-rules
BSD 3-Clause "New" or "Revised" License
628 stars 172 forks source link

Analyzer gives confusing directions (`combinators_ordering`) #4897

Closed johnmccutchan closed 2 months ago

johnmccutchan commented 4 months ago

Given the following code:

import 'dart:io' as io show Directory, exitCode, Platform, stderr;

The analyzer will complain:

   info - engine_tool/lib/main.dart:6:24 - Sort combinator names alphabetically. Try sorting the combinator names alphabetically. - combinators_ordering

But the names are sorted alphabetically.

The fix:

import 'dart:io' as io show Directory, Platform, exitCode, stderr;

seems wrong as it isn't alphabetically sorted (P comes after e).

The analyzer should be specific that it wants you to sort according to the ascii/utf-8 value of the characters.

bwilkerson commented 4 months ago

Or the lint should be changed to use a case-insensitive comparison.

@pq

pq commented 4 months ago

I'd be in favor of case-insensitive comparison in this case.

johnmccutchan commented 4 months ago

making that change will probably cause a bunch of existing code to be out of spec?

pq commented 4 months ago

It may very well. We'd want to do a bit of testing to measure impact first.

srawlins commented 2 months ago

Duplicate of https://github.com/dart-lang/linter/issues/3866