Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer_adjacent_string_concatenation should not warn for list elements #57796

Closed
zoechi opened this issue Oct 3, 2018 · 7 comments
Closed

prefer_adjacent_string_concatenation should not warn for list elements #57796

zoechi opened this issue Oct 3, 2018 · 7 comments
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive linter-set-recommended type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@zoechi
Copy link
Contributor

zoechi commented Oct 3, 2018

image

If I remove +, no_adjacent_strings_in_list warns instead

Dart VM version: 2.1.0-dev.6.0 (Thu Sep 27 09:51:34 2018 +0200) on "macos_x64"

@MichaelRFairhurst
Copy link
Contributor

MichaelRFairhurst commented Oct 3, 2018 via email

@bwilkerson
Copy link
Member

This is an interesting case. We have two rules that conflict in one specific scenario. I agree that in this case it makes more sense to change prefer_adjacent_string_concatenation, but it isn't clear to me whether the behavior should only be changed when both rules are enabled or to make the change unconditional. Unconditionally changing the behavior will make the rule's behavior more consistent and predictable, but means that we'll be missing cases where a lint could reasonably be expected by users that only enable that one rule.

@pq Interested to hear your thoughts.

@pq
Copy link
Member

pq commented Jul 29, 2021

In general, I think it'd be interesting to explore special cases where some rules might be mostly but not completely compatible (currently we only have the big hammer of tagging complete incompatibility). For this case we could probably make the change unconditionally --- I can't really imagine anyone wanting adjacent strings in lists [1]. That said, checking for the enablement of no_adjacent_strings_in_list could be done by accession options via the LinterContext.

context.analysisOptions.lintRules
        .map((lint) => lint.name)
        .contains('no_adjacent_strings_in_list');

(Untested.)

I guess I'm on the fence.

Whatever we do, it'd be good to update the rule docs to describe this nuance.

[1] I had to stop typing this to look and see and I admit I'm surprised to not see no_adjacent_strings_in_list in the core or recommended rulesets. @natebosch @munificent @jakemac53 @goderbauer : can any of you recall why we didn't?

@jakemac53
Copy link
Contributor

There is likely a performance cost to concatenating strings instead of using adjacent string literals? If so it would seem wrong to me that we would have a core lint that requires a less performant pattern, even if it does catch some bugs in programs?

The difference is likely small but 🤷‍♂️.

@natebosch
Copy link
Member

For this case we could probably make the change unconditionally --- I can't really imagine anyone wanting adjacent strings in lists

I do want adjacent strings in lists. Dartfmt indentation makes these fairly obvious.

@pq
Copy link
Member

pq commented Aug 10, 2021

Given @natebosch's rationale, I'm leaning towards marking this "do not fix". Exceptions can just be ignored.

@srawlins
Copy link
Member

Agreed.

@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive linter-set-recommended type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants