Files
sdk/pkg/analyzer/tool/diagnostics
Sam Rawlins 076dd1a2c0 Lint rule: prefer_interpolation, consider flattened chains
Fixes https://github.com/dart-lang/linter/issues/3814

This CL ends up solving a few problems, all rooted to one issue: binary
expressions were considered as they live in the syntax tree, but as they
are read by a human, they can be longer chains of additions.

1. We reported `'' + '' + ''` even though adding two string literals is
   considered OK. This is because the outer binary expression has
   `'' + ''` as its left operand, which isn't technically a string
   literal. This over-reporting is corrected.
2. Binary expressions inside string interpolations were not considered.
   This corrects that.
3. We can now report correctly the two issues in code like
   `x + '' + '' + x`.

Change-Id: If2a6fdf11d815d42d732cf2713b9e6dea3932e3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-23 16:40:09 +00:00
..