flutter_corelibrary icon indicating copy to clipboard operation
flutter_corelibrary copied to clipboard

Use positional arguments instead of manual string interpolation

Open PiotrRogulski opened this issue 10 months ago • 2 comments

This PR is purely technical and does not introduce any behavior changes.

Refactors lint codes to use built-in positional parameters (like {0}) in lint messages.

PiotrRogulski avatar Feb 16 '25 18:02 PiotrRogulski

Personally, I am not convinced to the benefits. This makes it much more susceptible to refactors. It is very easy to desync arguments: and {n} placeholders.

Yes, it is nice that it is built in. But Dart APIs are known to be designed in a pragmatic (???) rather than type safe way. We can build a small type safe wrapper?

shilangyu avatar Feb 17 '25 08:02 shilangyu

Personally, I am not convinced to the benefits. This makes it much more susceptible to refactors. It is very easy to desync arguments: and {n} placeholders.

Yes, it is nice that it is built in. But Dart APIs are known to be designed in a pragmatic (???) rather than type safe way. We can build a small type safe wrapper?

It is indeed unfortunate that the analyzer only accepts positional arguments. The main benefit is that we define the lints the way they're supposed to be defined. In particular, after this refactor, we create only one LintCode with the template string – this way, it's actually easier to keep the messages consistent, in my opinion

PiotrRogulski avatar Feb 17 '25 09:02 PiotrRogulski