Linter: no_adjacent_strings_in_list should trigger when the collection if is missing a trailing comma

Created on 12 Nov 2020  路  3Comments  路  Source: dart-lang/linter

Describe the issue
no_adjacent_strings_in_list should trigger when the collection if is missing a trailing comma.

To Reproduce

List<String> list = <String>[
  'a',
  'b'
  'c'
];

triggers the lint but

List<String> list = <String>[
  'a',
  if (true) 'b'
  'c'
];

does not.

Expected behavior
Lint warning: DON'T use adjacent strings in list. on the if (true) 'b' line.

Additional context
Real world bug:
https://github.com/flutter/flutter/pull/70325/files#diff-fbf1a86439c67e75e90a00f32fd2b789323582ced2f4f5cfea2d27a1af18aa30R427

bug flutter false negative

All 3 comments

I think the additional logic we need here is "no adjacent strings in collections or in collection elements"

I agree. This lint was probably missed when we added collection elements.

We may implement this with a new rule: https://github.com/dart-lang/linter/issues/2727

Was this page helpful?
0 / 5 - 0 ratings