Commit Graph

91 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 7320da0d19 linter: Add a PRESUBMIT check for example/all.yaml
Work towards https://github.com/dart-lang/sdk/issues/53578

Change-Id: Ia07d999abc2fcf4b8195c9f7688799bc099a1d88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341385
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-15 04:04:28 +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
Paul Berry a25eb56b70 Allow linter unit tests to be run from any directory.
I frequently run unit tests from the root directory of the SDK
package. Previous to this CL, that didn't work for the `linter`
package, because the test `validate_sdk_version_map.dart` contained a
hard-coded path that only worked if the test was invoked from the
`pkg/linter` subdirectory.

With this change, the test uses the `packageRoot` getter from the
`analyzer_utilities` package, which locates the SDK's `pkg` directory
using heuristics that work from a variety of different starting
directories, including the root of the SDK repo, anywhere within
`pkg/linter`, and in a Google3 bazel test.

Change-Id: I525ad21cb5228e670dadc98c05de18bddf3912e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339660
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-04 22:39:37 +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 bec6e82853 migration to driver.getAnalysisOptionsForFile (continued)
Change-Id: Ia22286786febe7e915df0d7e7b18b9657fef2b07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335063
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-11-14 22:41:28 +00:00
Sam Rawlins f2a001d2fd Reland: Improve file structure of linter files.
There is much code in pkg/analyzer/lib/src/lint which is only used by
_tests_ and _tools_ in the linter package. This CL attempts to tidy up
the separation of linter lib code and non-lib code by moving some
files, and moving some source elements, which are only used in tests,
or in tools.

I originally dug into this because I saw `LinterOptions` has a public late field
(dangerous):

`late file_system.ResourceProvider resourceProvider;`

It turns out this field is only initialized in tests and tools, and
then it's read by multiple methods, and it just so happens those
methods are only called during tests or in tools.

Summary of changes:

* Mark LintDriver and DartLinter classes as only used for linter tools
  and tests.
* Remove CamelCaseString class.
* Mark `DartLinter.lintPubspecSource` as `@visibleForTesting`.
* LinterOptions: mark `enabledLints` and `analysisOptions` final, and remove
  `resourceProvider`.
* Remove SourceLinter; it was only used in a few `engine_test.dart` tests in
  linter, but all uses could be replaced with DartLinter.
* Remove linter's `bin/linter.dart`; it is not meant to be used as any sort of
  user entrypoint. The main method is moved to `cli.dart`.
* Move linter's `lib/src/cli.dart` to `tool/cli.dart`.
* analyzer's top-level function `lintFiles`, classes ErrorWatchingSink
  and FileGlobFilter are moved to linter's tool/ directory.
* Delete the engine_test.dart tests which only validate basics of
  linter's old entrypoint.

This reverts commit d1bc88de8f.

Change-Id: I1063aa72c640ad8ab62f76bf89f665cb8b9952dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334645
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-11-10 21:25:11 +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
Oleh Prypin d1bc88de8f Revert "Improve file structure of linter files."
This reverts commit 31eab937f6.

Reason for revert: No way to import "tool/formatter.dart" in g3

Original change's description:
> Improve file structure of linter files.
>
> There is much code in pkg/analyzer/lib/src/lint which is only used by
> _tests_ and _tools_ in the linter package. This CL attempts to tidy up
> the separation of linter lib code and non-lib code by moving some
> files, and moving some source elements, which are only used in tests,
> or in tools.
>
> I originally dug into this because I saw `LinterOptions` has a public late field (dangerous):
>
> `late file_system.ResourceProvider resourceProvider;`
>
> It turns out this field is only initialized in tests and tools, and
> then it's read by multiple methods, and it just so happens those
> methods are only called during tests or in tools.
>
> Summary of changes:
>
> * Mark LintDriver and DartLinter classes as only used for linter tools
>   and tests.
> * Remove CamelCaseString class.
> * Mark `DartLinter.lintPubspecSource` as `@visibleForTesting`.
> * LinterOptions: mark `enabledLints` and `analysisOptions` final, and remove `resourceProvider`.
> * Remove SourceLinter; it was only used in a few `engine_test.dart` tests in linter, but all uses could be replaced with DartLinter.
> * Remove linter's `bin/linter.dart`; it is not meant to be used as any sort of user entrypoint. The main method is moved to `cli.dart`.
> * Move linter's `lib/src/cli.dart` to `tool/cli.dart`.
> * analyzer's top-level function `lintFiles`, classes ErrorWatchingSink
>   and FileGlobFilter are moved to linter's tool/ directory.
> * Delete engine_test.dart tests which only validate basics of
>   linter's old entrypoint.
>
> Change-Id: Ifc0e70454ee2ac794bc816ef9c77d5519a93eb0a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333128
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Phil Quitslund <pquitslund@google.com>

Bug: b/309643288
Change-Id: I69a731ff31507f671277d0395f4ebfbb86d8f607
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334660
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
2023-11-07 19:30:53 +00:00
Sam Rawlins 31eab937f6 Improve file structure of linter files.
There is much code in pkg/analyzer/lib/src/lint which is only used by
_tests_ and _tools_ in the linter package. This CL attempts to tidy up
the separation of linter lib code and non-lib code by moving some
files, and moving some source elements, which are only used in tests,
or in tools.

I originally dug into this because I saw `LinterOptions` has a public late field (dangerous):

`late file_system.ResourceProvider resourceProvider;`

It turns out this field is only initialized in tests and tools, and
then it's read by multiple methods, and it just so happens those
methods are only called during tests or in tools.

Summary of changes:

* Mark LintDriver and DartLinter classes as only used for linter tools
  and tests.
* Remove CamelCaseString class.
* Mark `DartLinter.lintPubspecSource` as `@visibleForTesting`.
* LinterOptions: mark `enabledLints` and `analysisOptions` final, and remove `resourceProvider`.
* Remove SourceLinter; it was only used in a few `engine_test.dart` tests in linter, but all uses could be replaced with DartLinter.
* Remove linter's `bin/linter.dart`; it is not meant to be used as any sort of user entrypoint. The main method is moved to `cli.dart`.
* Move linter's `lib/src/cli.dart` to `tool/cli.dart`.
* analyzer's top-level function `lintFiles`, classes ErrorWatchingSink
  and FileGlobFilter are moved to linter's tool/ directory.
* Delete engine_test.dart tests which only validate basics of
  linter's old entrypoint.

Change-Id: Ifc0e70454ee2ac794bc816ef9c77d5519a93eb0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333128
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-11-07 16:47:21 +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
pq 9266dd12ed add an "internal" rule state
Change-Id: I740d95c179005b820dab01b4cd0cd7b0976f288b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-10-18 16:27:22 +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
pq abe76b0fd9 disable rules.json validation
See: https://github.com/dart-lang/linter/issues/4756

Change-Id: I9e2d5858f313adcd6cd8323d696f3c82b460fc55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328684
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-29 17:49:43 +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 731d7dc1c6 [linter] Simplify some test support
* UseBuildContextSynchronously no longer needs an `inTestMode`
  parameter, since the test_data tests are migrated.
* `testRule`'s `debug` and `failOnErrors` parameters are never
  anything but the default, so removed, and simplified bool logic
  that follows.


Change-Id: I79653df45388a4eae655a38c16a41c0dcb43d73a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327709
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-09-26 17:08:57 +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