Skip to content

arguments_ordering

v1.0.0WarningConfigurableCode Organization

This rule flags a call whose named arguments are not in the configured order.

A call site with a dozen named arguments is a lookup table, and an unordered one has to be read end to end to answer “is this already set?”. Ordering keeps a diff honest too: a new argument lands in the middle where it can be seen, rather than appended beside a near-duplicate nobody noticed.

Positional arguments are never ordered, since their order is the call’s meaning and reordering them changes what it does.

This rule is in the pedantic preset. That preset supplies order: alphabetical and lowers min_arguments to 2; outside it the rule stays silent until an order is configured.

buildCard(
elevation: 2,
color: Colors.white,
padding: EdgeInsets.zero,
margin: EdgeInsets.zero,
borderRadius: BorderRadius.zero,
)
buildCard(
borderRadius: BorderRadius.zero,
color: Colors.white,
elevation: 2,
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
)

Outside preset: pedantic, this rule reports nothing until you choose an order:

many_lints.yaml
rules:
arguments_ordering:
order: alphabetical
analysis_options.yaml
many_lints:
rules:
arguments_ordering:
order: alphabetical
min_arguments: 5
Option Type Default Description
order string alphabetical, alphabetical_case_sensitive or by_length. Unset means the rule is silent
min_arguments int 5 How many named arguments a call needs before order is checked

To disable this rule:

many_lints.yaml
rules:
arguments_ordering: false

To keep the rule on but skip certain paths, use per-rule exclude.