solid-software / solid_lints

🟧 Lints for Dart and Flutter based on software industry standards and best practices.
Other
36 stars 17 forks source link

Using avoid_using_api for extension methods. #156

Open gaetschwartz opened 7 months ago

gaetschwartz commented 7 months ago

I want to prohobit the usage of Iterable<Future<T>>'s wait getter, but can't seem to find a way to match it. Here is the definition in dart:async:

extension FutureIterable<T> on Iterable<Future<T>> {
  Future<List<T>> get wait { /* ... */ }
}

I tried:

custom_lint:
  rules:
    - avoid_using_api:
      severity: info
      entries:
        - class_name: FutureIterable<T> // but also FutureIterable<dynamic, FutureIterable, Iterable, Iterable<Future>, Iterable<Future<dynamic>>, Iterable<Future<T>>
          identifier: wait
          source: dart:async
          reason: "Iterable.wait should be avoided because it loses type
            safety for the results. Use a Record's `wait` method
            instead."
          severity: warning

but to no success. Without specifiying the class_name works but does match the (f1,f2).wait getter method I don't want to match.

illia-romanenko commented 7 months ago

@getBoolean have you tried anything like that?

getBoolean commented 7 months ago

I haven't tested against extension methods, it might not be handled properly by the current implementation. I'll look into it.