Commit Graph

76 Commits

Author SHA1 Message Date
Parker Lougheed 3e2ac6721d [linter] Report deprecated_consistency only on constructor name
Before this fix the lint was being reported on the entire constructor definition.

Also moves all tests to be reflective.

Change-Id: I8e32600cd87a7f34f8e8aa701acf180c741b915a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-18 18:02:42 +00:00
Sam Rawlins e1bec8d7d6 linter: prefer_collection_literals; fix reports in ctor initializers, conditionals
Change-Id: Ie56201b717b3af482b22f8449b4eb9ae1a329669
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341394
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-12-14 22:05:40 +00:00
Sam Rawlins a2151474a5 linter: UBCS: require checking the correct 'mounted' property
Fixes https://github.com/dart-lang/linter/issues/4777

Change-Id: I0c50ab1a04b8f9c704a0cf787fcf414688cd61a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330561
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-12 01:34:11 +00:00
Brian Wilkerson a155e2b521 Remove the avoid_unstable_final_fields lint
Change-Id: I6835df32fc6c0d9a5f17b3b5344353ec061147d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340386
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-08 15:50:09 +00:00
Parker Lougheed 844fd8deb0 [linter] Don't trigger avoid_classes_with_only_static_members on sealed classes
If someone is declaring a sealed class with subclasses, it's likely meant for exhaustiveness, and it should be okay to have just static members.

Change-Id: I4938794c3095ca295495ec6f421f8e6e3d3935ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340140
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-07 20:07:12 +00:00
Parker Lougheed 790657f1da [linter] Report public_member_api_docs on just constructor names or types
Without this change, the lint triggers on the entire definition, including the body. That makes it hard to visually identify the target of the lint.

Change-Id: I0071f56f68e73fdfbad28cfa74d71ea3979d7a2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340142
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-12-06 20:50:16 +00:00
Parker Lougheed 80ad96837c [linter] Add field and super parameter tests for comment_references lint
The core issue was solved in https://github.com/dart-lang/sdk/commit/c8b18439d48a3acd7a8c73b6539265708f4417dc.
This CL adds tests to verify the linter correctly finds the associated static elements and doesn't report a comment_references lint.

Closes https://github.com/dart-lang/linter/issues/3563

Bug: https://github.com/dart-lang/linter/issues/3563
Change-Id: Icf281faf1934b135b51e98271be461b527b83a14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339061
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-02 22:43:35 +00:00
Sam Rawlins 030fe115e2 linter: Allow dynamic calls on explicit dynamic- or Function-casts
Fixes https://github.com/dart-lang/linter/issues/4806

Change-Id: I6c900f9aa3d7c2cf8dc3547bfe035eab820e750b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339101
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-11-30 22:40:18 +00:00
Paul Berry a19ae4ee68 Enable the extension types language feature.
This language feature allows the user to declare a static type using
`extension type` syntax, for example:

    extension type IdNumber(int i) {
      operator <(IdNumber other) => i < other.i;
      bool isValid(Some parameters) => ...;
    }

This behaves similarly to a "wrapper" class:

    class IdNumber {
      final int i;
      IdNumber(this.i);
      operator <(IdNumber other) => i < other.i;
      bool isValid(Some parameters) => ...;
    }

However, at runtime, no wrapper objects are created; instead, an
instance of the extension type is represented directly by its
"representation type" (`int` in the above example), and methods like
`isValid` are resolved statically. This gives developers an
abstraction mechanism with the advantage of zero runtime performance
cost, since no extra heap space is required, and no extra instructions
are needed to convert between an extension type and its underlying
representation.

The disadvantage of using extension types as an abstraction mechanism
is that since no wrapper objects are created at runtime, the
abstraction can be bypassed using `dynamic`, runtime casts, or by
"laundering" the object through contravariant generic methods like
`List.add` (which are runtime checked in Dart). For example:

    main() {
      var id = IdNumber(1);
      var list1 = <int>[];
      List<Object> list2 = list1;
      list2.add(id); // OK at compile time because `IdNumber` is a
                     // subtype of `Object`. OK at runtime because
		     // at runtime, `IdNumber` and `int` are
		     // indistinguishable.
      int i = list1[0];
      print(i);
    }

Extension types are expected to be particularly useful for
low-overhead decoding of external data formats (such as JSON), and for
inter-operation with other languages (such as Javascript).

For additional information see the feature specification:
https://github.com/dart-lang/language/blob/main/accepted/future-releases/extension-types/feature-specification.md

Change-Id: I900a3a25dcfc38bfa9c9f9b5b9fa20f362883653
Tested: Standard trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335062
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-11-21 19:14:49 +00:00
pq 4dcdfc57d6 enable flutter_style_todos
(The bulk of these fixes where auto-applied by `dart fix`)

Change-Id: I5476294ca63ee6584ee07af1ae448db7ba07760e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335324
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-09 22:01:47 +00:00
Sam Rawlins 716b127a1a linter: ubcs: account for when clauses in if-like nodes
Fixes https://github.com/dart-lang/linter/issues/4795

Change-Id: I4cce15ddaf8a669921646fa81dd0e455859e46e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332361
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-26 19:56:58 +00:00
pq 2ae5b4f9eb add (internal) erase_dart_type_extension_types stub
Very much a WIP but hopefully provides enough scaffolding for some dev_compiler experimentation.



Change-Id: Ic0cfe3c30b189732ee10209ff8b4b6a88ef0d37d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330995
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-10-19 16:10:19 +00:00
pq 5b7f451360 avoid_type_to_string extension type tests
Fixes: https://github.com/dart-lang/linter/issues/4783

Change-Id: I1477048ea933cdc7f11706a9caab3f0769d66f86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331082
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-18 16:34:34 +00:00
Sam Rawlins 20dae1a3f6 linter: catch fields referenced in a pattern field
Fixes https://github.com/dart-lang/sdk/issues/53674

Change-Id: I87effd3cc4b3d3227cd26c3fdeb68b7f7e2d0ca9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330880
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-10-17 19:54:48 +00:00
Sam Rawlins 06ab207091 linter: Move many unnecessary_statements tests
Not all of them; there are too many for one change.

Change-Id: I59f6a52c03ccbc4f5f81567b0f70c32fcf4b1f2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329569
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-10-13 03:51:23 +00:00
Sam Rawlins 7341ad214e Document unreachable_from_main for instance members
Change-Id: I37ea317ad0e1fc18d509e706a3cbc355f04005be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330380
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-13 03:39:23 +00:00
pq 532e4674c6 extension type support for prefer_const_constructors_in_immutables
Fixes: https://github.com/dart-lang/linter/issues/4720

Change-Id: Ia55289f53b6191e8511664cfa5b05ebcfe42ed6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-12 17:41:12 +00:00
pq 3f3def4654 verify prefer_asserts_in_initializer_lists for extension types
As it happens, `prefer_asserts_in_initializer_lists` works out of the box for constructors in extension types. (Yay!) This just adds a few tests for coverage.

Fixes: https://github.com/dart-lang/linter/issues/4779

Change-Id: I1f5ffbbc968b37723b5e6894227c154563b2803c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330031
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-12 16:01:28 +00:00
Erik Ernst cdc16e7d3d Create lint PR 3578 as Gerrit CL
This CL transfers the changes made by
https://github.com/dart-lang/linter/pull/3578
to Gerrit.

Change-Id: Ib1eae56d2112e25bcf9916abf27b05bd3de15735
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326342
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-10-12 10:09:10 +00:00
pq d9731acfda fix prefer_void_to_null false positive on extension type representations
Fixes: https://github.com/dart-lang/linter/issues/4720

Change-Id: Ie3a736cbd4d190135eb77932ec8ba9352683226e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-11 19:04:08 +00:00
Sam Rawlins ac7059a832 Support extension types in unreachable_from_main
Work towards https://github.com/dart-lang/linter/issues/3625

Change-Id: I41a28795f16eb19b41f864ef512cf10936c2e11f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327713
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-10-11 01:11:28 +00:00
Parker Lougheed fd59a1c33f [linter] Reduce cases where dynamic is inferred
Doesn't enable strict-inference but fixes a few of the more impactful cases.

Change-Id: Ife08f1839036c420108bf603f4bce3ab7bfea5c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330000
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-10-10 18:07:59 +00:00
Sam Rawlins 9ed15c1552 linter: move prefer_const_constructors_in_immutables tests
Change-Id: I554788acea66bfd148f8f2a381046e4f1acae3f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329141
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-09 18:16:47 +00:00
Sam Rawlins 8d80d978ad linter: Move avoid_multiple_declarations_per_line tests
Change-Id: I92271ad7999c521ea343c3199dc09f32a897b0c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329140
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-06 23:23:52 +00:00
Sam Rawlins a6eb0d08db Linter: move control_flow_in_finally tests
Change-Id: Idf1aaea14ead44969fb8d978b74d33e77aa2dc68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328767
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-04 21:51:14 +00:00
Sam Rawlins bdb450bd03 Move avoid_web_libraries_in_flutter tests
Work towards https://github.com/dart-lang/linter/issues/3535

Change-Id: I7adf8986b3e3ab5329599d608df6f90db8046179
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327281
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-25 22:04:58 +00:00
Sam Rawlins e28faa2462 linter: use_build_context_synchronously: fix or
This PR fixes the case demonstrated in the new test, where
a mounted check occurs on the right side of an or-binary
expression.

Fixes https://github.com/dart-lang/linter/issues/4753

Change-Id: I3c4ac8a42f7f87502fb217763506fa5294f6b017
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326864
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-20 21:49:54 +00:00
Sam Rawlins 83c145aec4 linter: Move avoid_catching_errors tests
Change-Id: I60f8e15cb5e2e647d63094cc61cb0594cddb2321
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326867
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-09-20 21:41:51 +00:00
Sam Rawlins 42516e3c6e linter: Move close_sinks tests
Work towards https://github.com/dart-lang/linter/issues/3535

Change-Id: I5c2b076d5d01037aa50b829d29a899834e105181
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326861
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-09-19 20:17:13 +00:00
Sam Rawlins 29f78ef98c linter: Move final use_build_context_synchronously tests
Most of the tests removed here already are covered in the new tests.

And also two test cases are added.

Change-Id: I3d6e15d2b9fde14a2b2249a3422ca1508a0d7572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326726
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-19 16:34:59 +00:00
Sam Rawlins b72f968334 Move avoid_print tests
In this CL, I also add the foundation file, and move some existing
elements into it, and correct all of the necessary tests.

Change-Id: I772f76d6eaf64612667a445270f86741a4771ce8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326684
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-09-19 15:56:48 +00:00
pq d1b6ea9f4d +annotate_redeclares
Fixes: https://github.com/dart-lang/linter/issues/4747

Change-Id: I7bf3e83dbe279f5b1a03dc5e5806c7c0fe3e3486
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326263
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-18 02:41:29 +00:00
Sam Rawlins 6170698492 [linter] Move avoid_unnecessary_containers tests
Change-Id: Id516f3543a0bc319a2513e739828f563fa91afe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326560
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-18 01:03:59 +00:00
Sam Rawlins 45f7b438bd linter: Move sort_child_properties_last tests
Change-Id: I5d369a3a911695681713060ebf0bfb1239078087
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326541
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-18 01:03:11 +00:00
Sam Rawlins 6d6ce9c1c3 linter: Move use_decorated_box tests
Change-Id: Ie2b37e54546806da0da362f29ac6a654146d4ede
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326244
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-09-15 23:27:13 +00:00
Sam Rawlins 66b58414eb Move diagnostic_describe_all_properties tests
Change-Id: I541f7e9a39b3b0f3de60cf68117e643ba5b661b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325966
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-14 17:33:34 +00:00
Sam Rawlins 30c98b7c36 linter: Migrate fixnum-related tests to be reflective
Change-Id: I2dbe12c2d2c66d08a2439a37c112cd08e5414204
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325902
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-09-13 23:34:59 +00:00
Sam Rawlins 10da52b016 linter: Move sized_box_shrink_expand tests
Change-Id: I8fccc19af7ed2895b710e00feae3145e6ff8e401
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325480
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-09-12 22:16:59 +00:00
Sam Rawlins 02dba4189f linter: Move prefer_foreach tests
Change-Id: I0a6beae9d4983c8bef3445b569fc163c41f66faa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325361
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-09-11 23:17:30 +00:00
Parker Lougheed 08a1093cd4 [linter] Focus omit_local_variable_types on type itself
The lint was being reported on the entire expression, making it potentially hard to identify the source of the lint. This change moves the range to the type itself, now matching the existing behavior of the lint in for each loops.

Change-Id: Id4a7c487aadb6282515c7ef5bb0fd8ebf923d8eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325161
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-09-11 17:51:59 +00:00
pq 8a5ddecfb3 + extension type target kind (and @optionalTypeArgs support)
Adds a new TargetKind for extension types and adds it to `@optionalTypeArgs`.

Change-Id: I7254c1299c296451b9adc5d1f8eceb50af66f039
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324769
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-09-08 18:09:01 +00:00
Sam Rawlins 4176e16c59 linter: Move avoid_slow_async_io tests
Change-Id: Ic8a1e3ecd10b635b5f353ecbbabc942905fd2832
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324482
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-07 17:09:53 +00:00
pq 2221dc01dc extension type support for avoid_types_as_parameter_names
Fixes: https://github.com/dart-lang/linter/issues/4744

Change-Id: I7db548e484c719450f6608876fa2a325f0a3c784
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324621
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-07 00:09:30 +00:00
Sam Rawlins b4309860f9 [linter] Move null_closures tests
Change-Id: I071bb39750c08f05137ba244298b3d13309b5585
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324540
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-06 16:11:32 +00:00
Sam Rawlins ee44a1b0f0 [linter] Move unsafe_html tests
Change-Id: I3da2f56e6f5c389e8389c954c1d565c2e1643e4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324561
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-06 16:10:28 +00:00
Sam Rawlins 4bddf8a25f Revert "Revert "linter: Refactor prefer_collection_literals to use context type more""
This reverts commit cbdae14d2f.

In addition, Fix prefer_collection_literals for methods with expression bodies

Original description:

linter: Refactor prefer_collection_literals to use context type more

There is a basic premise in this rule which we cannot satisfy exactly:
we need to disallow `LinkedHashSet()` unless the context type requires
the developer to use `LinkedHashSet`. But the context type is long
gone when the lint rule is run.

This CL adds some logic to try to attempt figuring out the context
type in the cases where users have filed bugs, but it will never be
super accurate.

Fixes https://github.com/dart-lang/linter/issues/4736
Fixes https://github.com/dart-lang/linter/issues/3057
Fixes https://github.com/dart-lang/linter/issues/1649
Fixes https://github.com/dart-lang/linter/issues/2795

Change-Id: I958ba69a56866c18523ce6cbf62645ef8e028f6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324260
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-09-05 23:49:49 +00:00
pq ee2bc9d870 highlight the late token in unnecessary_late reports
Fixes: https://github.com/dart-lang/linter/issues/4742

Change-Id: Ia13a325dc44a49f5aab3d564f3adc0c10e80c4f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-05 18:49:26 +00:00
Sam Rawlins cfcd047658 Move prefer_final_parameters tests
Change-Id: Iedf9c03e53b09bd85037f49aa13a10a2d9ed1df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323945
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-09-05 18:48:57 +00:00
Ilya Yanok cbdae14d2f Revert "linter: Refactor prefer_collection_literals to use context type more"
This reverts commit cd8a3370e7.

Reason for revert: lint starts barking at the wrong tree: b/298917960

Original change's description:
> linter: Refactor prefer_collection_literals to use context type more
>
> There is a basic premise in this rule which we cannot satisfy exactly:
> we need to disallow `LinkedHashSet()` unless the context type requires
> the developer to use `LinkedHashSet`. But the context type is long
> gone when the lint rule is run.
>
> This CL adds some logic to try to attempt figuring out the context
> type in the cases where users have filed bugs, but it will never be
> super accurate.
>
> Fixes https://github.com/dart-lang/linter/issues/4736
> Fixes https://github.com/dart-lang/linter/issues/3057
> Fixes https://github.com/dart-lang/linter/issues/1649
> Fixes https://github.com/dart-lang/linter/issues/2795
>
> Change-Id: I3e6c6de81084dca2825488c89830ab3e7ea63186
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323680
> Reviewed-by: Phil Quitslund <pquitslund@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

Change-Id: I980053dd51ffd4447721e0ad7436b07ca704b554
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324021
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2023-09-04 10:43:54 +00:00
Sam Rawlins 0a567d01e5 linter: Move unnecessary_this tests
Change-Id: I689feebb74a03e810853faf5f3d2d7dd917701b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323962
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-09-01 22:47:59 +00:00