Summary
The count == 1 ? 'drink' : 'drinks' ternary is now inlined at four call sites, past the "extract a helper at 3+ repetitions" threshold in AGENTS.md.
Call sites
| File |
Context |
lib/widgets/festival_header.dart:21 |
'$drinkCount ${drinkCount == 1 ? 'drink' : 'drinks'}' |
lib/screens/my_festival_screen.dart:210 |
section semantics label |
lib/widgets/drink_filter_sheets.dart |
category row semantics label |
lib/widgets/drink_filter_sheets.dart |
style row semantics label |
The last two were added in #506 after review flagged that those labels announced "1 drinks" to screen readers.
Why it is worth doing
The failure mode is silent and accessibility-facing: a new label that forgets the ternary reads "1 drinks" to a screen reader and nothing fails. Two of the four sites had exactly that bug until it was caught in review, which is evidence the inline form does not survive copy-paste.
Suggested fix
A small helper — e.g. String drinkCountLabel(int count) in lib/utils/ — returning '$count drink' / '$count drinks', with a unit test covering 0, 1 and 2. Update all four sites.
Deliberately not done as part of #506: two of the four call sites are in files unrelated to that change, and widening the diff into them would have been scope creep.
Impact
Low. No user-visible defect today — all four sites are currently correct. This is about stopping the fifth one from being wrong.
Summary
The
count == 1 ? 'drink' : 'drinks'ternary is now inlined at four call sites, past the "extract a helper at 3+ repetitions" threshold in AGENTS.md.Call sites
lib/widgets/festival_header.dart:21'$drinkCount ${drinkCount == 1 ? 'drink' : 'drinks'}'lib/screens/my_festival_screen.dart:210lib/widgets/drink_filter_sheets.dartlib/widgets/drink_filter_sheets.dartThe last two were added in #506 after review flagged that those labels announced "1 drinks" to screen readers.
Why it is worth doing
The failure mode is silent and accessibility-facing: a new label that forgets the ternary reads "1 drinks" to a screen reader and nothing fails. Two of the four sites had exactly that bug until it was caught in review, which is evidence the inline form does not survive copy-paste.
Suggested fix
A small helper — e.g.
String drinkCountLabel(int count)inlib/utils/— returning'$count drink'/'$count drinks', with a unit test covering 0, 1 and 2. Update all four sites.Deliberately not done as part of #506: two of the four call sites are in files unrelated to that change, and widening the diff into them would have been scope creep.
Impact
Low. No user-visible defect today — all four sites are currently correct. This is about stopping the fifth one from being wrong.