Skip to content

Commit

Permalink
prefer_interpolation_to_compose_strings should apply only for String.+ (
Browse files Browse the repository at this point in the history
  • Loading branch information
a14n committed May 21, 2021
1 parent fbbd359 commit ce5c72d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/src/rules/prefer_interpolation_to_compose_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ class _Visitor extends SimpleAstVisitor<void> {
if (leftOperand is StringLiteral && rightOperand is StringLiteral) {
return;
}
if ((leftOperand.staticType?.isDartCoreString ?? false) ||
(rightOperand.staticType?.isDartCoreString ?? false)) {
if (leftOperand.staticType?.isDartCoreString ?? false) {
DartTypeUtilities.traverseNodesInDFS(node).forEach(skippedNodes.add);
rule.reportLint(node);
}
Expand Down
7 changes: 7 additions & 0 deletions test_data/rules/prefer_interpolation_to_compose_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ issue2490() {
final String foo = 'Hello';
final String bar = foo + r' /world\'; // OK
}

class Issue792 {
Issue792 operator +(String other) => this;
f() {
var a = this + ' '; // OK
}
}

0 comments on commit ce5c72d

Please sign in to comment.