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
Paul Berry
428cdffbc0
Linter: fix unnecessary_parenthesis handling of (a?[b]) : c
...
There are two possible meanings of `?` when it follows an expression:
it could introduce a null-aware index operation (`a?[b]`), or it could
introduce a conditional expression (`a?b:c`). The parser always favors
the second interpretation (see
https://github.com/dart-lang/language/blob/main/accepted/2.12/nnbd/feature-specification.md#null-aware-subscript ).
Therefore, if the user wants to use a null-aware index operation in a
context where it is followed by a `:` and then another expression,
parentheses are required around the null-aware index operation, to
prevent the token sequence from being interpreted as a conditional
expression.
This can happen in two circumstances:
- In the "then" part of a conditional expression: `a ? (b?[c]) : d`
- In a map literal key: `{(a?[b]): c}`
The `unnecessary_parenthesis` lint already has a number of exceptions
to handle weirdnesses of the parser; we just need to add one more.
Fixes https://github.com/dart-lang/linter/issues/4812 .
Bug: https://github.com/dart-lang/linter/issues/4812
Change-Id: I265103e257d45bfd228972aebba595097b429522
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339480
Reviewed-by: Samuel Rawlins <srawlins@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
Reviewed-by: Phil Quitslund <pquitslund@google.com >
2023-12-04 17:48:38 +00:00
Sam Rawlins
dd6c961bf0
Remove all pre-NNBD support in the linter code
...
In this CL we "remove" 3 linter rules, and any subsequently unused quick fixes:
* `always_require_non_null_named_parameters`
* `avoid_returning_null`
* `avoid_returning_null_for_future`
We also delete any code that branched on pre-NNBD libraries; these are
no longer supported.
Change-Id: I3bad7a44de3563e5737919c878170213ad506b82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336244
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Reviewed-by: Phil Quitslund <pquitslund@google.com >
Commit-Queue: Samuel Rawlins <srawlins@google.com >
2023-11-21 18:55:01 +00:00
Sam Rawlins
93541c708c
linter: Remove two deprecated linter rules
...
Fixes https://github.com/dart-lang/linter/issues/4800
Change-Id: I4eef17ca19ea7469fba372c28eef7618249c48dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334080
Reviewed-by: Phil Quitslund <pquitslund@google.com >
Commit-Queue: Samuel Rawlins <srawlins@google.com >
2023-11-09 17:03:15 +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
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
pq
0742604758
clean up references to dart test
...
See: https://github.com/dart-lang/linter/issues/4754
Change-Id: Ib875e1640dd15f321362f2dba76b3d5d8524497c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328183
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Commit-Queue: Phil Quitslund <pquitslund@google.com >
Reviewed-by: Samuel Rawlins <srawlins@google.com >
2023-09-27 21:54:09 +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
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
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
pq
dd970ba17e
de-duplicate mocked package:meta
...
(We should do the same for `package:flutter` but that will likely require some updates to the version stored in server.)
Change-Id: I262886a3522e19f86a7ba4ae46a50c48090c8d95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Commit-Queue: Phil Quitslund <pquitslund@google.com >
2023-09-08 18:05:48 +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
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
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
Sam Rawlins
cd8a3370e7
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 >
2023-09-01 19:58:29 +00:00
Sam Rawlins
d0273dda5f
linter: Move no_runtimeType_toString tests
...
Also re-order the skip checks, to avoid walking up ancestors on
every method call that isn't named 'toString'.
Change-Id: I69e9b58b1ae26d44498381546d5881c7e66d4935
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323681
Auto-Submit: Samuel Rawlins <srawlins@google.com >
Commit-Queue: Samuel Rawlins <srawlins@google.com >
Reviewed-by: Phil Quitslund <pquitslund@google.com >
2023-09-01 18:51:18 +00:00
pq
5d3d43bf2d
remove experiment tests
...
Fixes: https://github.com/dart-lang/linter/issues/4734
Change-Id: If39807f0a97641d33b879fab7d5c5fc408e69847
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323447
Commit-Queue: Phil Quitslund <pquitslund@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
2023-08-30 18:37:25 +00:00
pq
6a2c9cb826
migrate tighten_type_of_initializing_formals nnbd experiment tests
...
Fixes: https://github.com/dart-lang/linter/issues/4732
Change-Id: Ia6c0c5c28ddd7dc35dfc4c45dbc28c77a3a70a68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323441
Commit-Queue: Phil Quitslund <pquitslund@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
2023-08-30 17:35:43 +00:00
pq
595b6542a0
migrate unnecessary_nullable_for_final_variable_declarations nnbd experiment tests
...
Fixes: https://github.com/dart-lang/linter/issues/4733
Change-Id: I6fbcd42719be924e463bb03d1998706f2ab3d645
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323442
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Commit-Queue: Phil Quitslund <pquitslund@google.com >
2023-08-30 17:35:38 +00:00
Sam Rawlins
520a7c96df
[linter] Move prefer_function_declarations tests
...
Change-Id: Ib0f51425c7594060fd3dbcf9e9d6651ab4aaedf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323420
Auto-Submit: Samuel Rawlins <srawlins@google.com >
Commit-Queue: Phil Quitslund <pquitslund@google.com >
Reviewed-by: Phil Quitslund <pquitslund@google.com >
2023-08-30 17:10:50 +00:00
pq
21d50c276f
migrate void_checks nnbd experiment tests
...
Fixes: https://github.com/dart-lang/linter/issues/4731
Change-Id: I97e15192c3ced2575c7db99b31e70a744df3de3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323440
Commit-Queue: Phil Quitslund <pquitslund@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
2023-08-30 16:50:50 +00:00
pq
ba9f103a10
migrate unnecessary_null_in_if_null_operators nnbd experiment tests
...
Fixes: https://github.com/dart-lang/linter/issues/4730
Change-Id: I8128cf93a733f0b002af458961f3626f0de1ab96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323229
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Commit-Queue: Phil Quitslund <pquitslund@google.com >
2023-08-30 15:41:15 +00:00
Sam Rawlins
a10ee7a2ce
[linter] Move use_raw_strings tests
...
Change-Id: I70f1aadcb2216a5d328632ad2804e592e5f03804
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323225
Commit-Queue: Phil Quitslund <pquitslund@google.com >
Auto-Submit: Samuel Rawlins <srawlins@google.com >
Reviewed-by: Phil Quitslund <pquitslund@google.com >
2023-08-29 20:54:20 +00:00
pq
3b7933dfb0
migrate avoid_returning_null nnbd experiment test
...
Fixes: https://github.com/dart-lang/linter/issues/4726
Change-Id: Ifbb056c046be24d1f153662ea6bbf66334ab2ca9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323222
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Commit-Queue: Phil Quitslund <pquitslund@google.com >
2023-08-29 20:00:40 +00:00
pq
dce9ffa5ce
migrate unrelated_type_equality_checks nnbd experiment test
...
Fixes: https://github.com/dart-lang/linter/issues/4727
Change-Id: I2b6c370a09b141f63745de11ffe18f158b5b3527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323223
Commit-Queue: Phil Quitslund <pquitslund@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
2023-08-29 19:56:14 +00:00
pq
da075f7829
migrate type_init_formals nnbd experiment test
...
Fixes: https://github.com/dart-lang/linter/issues/4728
Change-Id: Ice8abf3a83ec5303353dbb9c4c308f08316beca4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Commit-Queue: Phil Quitslund <pquitslund@google.com >
2023-08-29 19:52:37 +00:00
William Hesse
86c86d638a
Add linter repository to sdk, preserving its commit history
...
Added using git-subtree command git subtree add -P pkg/linter linter/main
Bug: https://github.com/dart-lang/linter/issues/4411
2023-08-23 14:05:34 +02:00