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

dart fix doesn't trigger on extra_positional_arguments lint #54668

Open
goderbauer opened this issue Jan 18, 2024 · 2 comments
Open

dart fix doesn't trigger on extra_positional_arguments lint #54668

goderbauer opened this issue Jan 18, 2024 · 2 comments
Labels
analyzer-data-driven-fixes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@goderbauer
Copy link
Contributor

For a repro create the following files:

lib/fix_data/foo.yaml

version: 1
transforms:
  - title: 'Remove extra positional'
    date: 2020-11-20
    element:
      uris: ['foo.dart']
      method: 'foo'
      inClass: 'Foo'
    changes:
      - kind: 'removeParameter'
        index: 1

lib/foo.dart

class Foo {
  // This method used to have an extra `String b` parameter, that was removed.
  void foo(int a) {}
}

lib/bar.dart

import 'foo.dart';

void main() {
  // 🔥 This line needs to get fixed to remove the "hello" argument.
  Foo().foo(1, "hello");
}

pubspec.yaml

name: dart_fix_repo
version: 1.2.3

environment:
  sdk: '>=2.12.0 <3.0.0'

Running dart analyze shows that there is an issue:

  error • lib/bar.dart:4:15 • Too many positional arguments: 1 expected, but 2 found. Try removing the extra arguments. • extra_positional_arguments

However, dart fix says there's nothing to fix:

% dart fix --dry-run
Computing fixes in dart_fix_repo (dry run)... 0.5s
Nothing to fix!

The expectation is that this command would have changed the line above marked by 🔥 to be Foo().foo(1);, but it sadly doesn't do that.

@goderbauer
Copy link
Contributor Author

Pure speculation: I wonder if the problem is that the analyzer issue is on the argument (see screenshot below) and not on the method that the dart fix is targeting in the element clause?

Screenshot 2024-01-18 at 10 11 29 AM

@bwilkerson
Copy link
Member

That could well be the problem.

@keertip

@bwilkerson bwilkerson added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-data-driven-fixes labels Jan 18, 2024
@pq pq added the P2 A bug or feature request we're likely to work on label Jan 18, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this issue Jan 19, 2024
Much nicer calling API and simplifies evolving this API in the future.

I wish we could write a dart fix for this, but that's blocked on dart-lang/sdk#54668.
@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-data-driven-fixes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants