dart-lang / linter

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

`avoid_positional_boolean_parameters` ignored when in function-only-parameter #4349

Open FMorschel opened 1 year ago

FMorschel commented 1 year ago

I'm proposing here that avoid_positional_boolean_parameters could be ignored in function-only-parameter cases.

Bad Examples

Task(true);
Task(false);
ListBox(false, true, true);
Button(false);

//New Case:
Task.doSomething(object, true);

Good Examples

Task.oneShot();
Task.repeating();
ListBox(scroll: true, showScrollbars: true);
Button(ButtonState.enabled);

//New cases: 
object.select(true);
dataRow.onSelectionChanged(true);

Discussion

I believe that when using boolean parameters as the only parameter in the function, is most likely a function that has a meaningful name for that value already. Similar to the ones I mentioned above in the actual Flutter repo (onSelectionChanged).

Discussion checklist

srawlins commented 1 year ago

This is largely a duplicate of https://github.com/dart-lang/linter/issues/1638, sort of an alternative solution to that issue.