Skip to content

dart fix doesn't trigger on extra_positional_arguments lint #54668

@goderbauer

Description

@goderbauer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions