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

[lint] prefer_final_locals quick-fix #51721

Closed
Punt13140 opened this issue Mar 13, 2023 · 7 comments
Closed

[lint] prefer_final_locals quick-fix #51721

Punt13140 opened this issue Mar 13, 2023 · 7 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Punt13140
Copy link

Hi,

Since a few days, my IDE (IntelliJ) does not provide a quick-fix (which is just adding the final keyword) for prefer_final_locals rule.

I've tried with Visual Code, and I'm having the same problem.

@lrhn lrhn added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Mar 13, 2023
@srawlins
Copy link
Member

Thanks for filing an issue, can you provide a small reproduction of code for which you wish to have the quick fix, but it isn't offered? Thanks!

@srawlins srawlins added needs-info We need additional information from the issue author (auto-closed after 14 days if no response) type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Mar 19, 2023
@Punt13140
Copy link
Author

Hi @srawlins,

...everywhere ?

It was working fine, I've been adding final everywhere it was recommended thanks to this quick-fix.
And now I only have the suggestion.

example:

  @override
  Widget build(BuildContext context) {

    List<Widget> modalTiles = [];
    Job job = state.lstJobs!.elementAt(index);
    Size screenSize = MediaQuery.of(context).size;-
    MyColors myColors = Theme.of(context).extension<MyColors>()!;
    //...

@github-actions github-actions bot removed the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Mar 20, 2023
@srawlins
Copy link
Member

Thanks for the bug report and the repro!

@scheglov
Copy link
Contributor

Do you expect to keep type annotations, but append final?
I.e. convert

void f() {
  int v = 0;
  print(v);
}

into

void f() {
  final int v = 0;
  print(v);
}

@scheglov scheglov self-assigned this Mar 21, 2023
@scheglov scheglov added the P3 A lower priority bug or feature request label Mar 21, 2023
@scheglov
Copy link
Contributor

copybara-service bot pushed a commit that referenced this issue Mar 21, 2023
…notations.

Bug: #51721
Change-Id: If99fa9e84eabe4099dcfa674540e27f323eddd65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290261
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@Punt13140
Copy link
Author

Hi ,

I was on another project (not Dart/Flutter related) so I did not had the time to check if it was fix.

But right now, the quick-fix is not working @scheglov.

Am I suppose to not keep type annotations ?
IMO it is much more readable to keep the type

@srawlins
Copy link
Member

@Punt13140 if you are not using the latest Dart/Flutter on the beta or master channel, you won't have this fix yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants