Commit graph

316 commits

Author SHA1 Message Date
Sam Rawlins 4f5dc5603f analyzer: Deprecate dead properties on Comment
Work towards https://github.com/dart-lang/sdk/issues/56038

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: If7ae2738fec598f16756c524b6bd6c258ee5609e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
2024-06-18 18:27:25 +00:00
Parker Lougheed 91254e4064 [analyzer/linter] Surface links to available lint diagnostic messages
Dependent on https://github.com/dart-lang/site-www/pull/5914 landing first.

Bug: https://github.com/dart-lang/site-www/issues/4498
Change-Id: I378debd5d484e17f18d59c49173a5d010f05b6df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371785
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Sam Rawlins <srawlins@google.com>
2024-06-17 14:51:31 +00:00
Sam Rawlins 3c65563735 linter: Fix issue with extension type methods as possibly const arguments
Fixes https://github.com/dart-lang/linter/issues/4978

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I532f491355bc34028b19d323102f038dff861445
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371780
Auto-Submit: Sam Rawlins <srawlins@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-06-14 19:42:24 +00:00
Sam Rawlins 21829623da linter: move avoid_js_rounded_ints tests
Change-Id: Ie569dba08fa0bf6fc25447b39015be381e79fe7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370461
Auto-Submit: Sam Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-06-12 08:38:35 +00:00
pq 9544fe9641 [wildcards] local and parameter scopes
Update wildcard variable scopes.

See:  https://github.com/dart-lang/sdk/issues/55862 and https://github.com/dart-lang/sdk/issues/55680.

See discussion on related/ updated co19 test (`co19/LanguageFeatures/Wildcards/wildcards_do_not_shadow_A01_t04`) here: https://github.com/dart-lang/co19/issues/2698.





Change-Id: I388895ef7bac69617700504a964ce9f3021b2d24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368526
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-06-11 08:14:35 +00:00
Sam Rawlins eee06a5f8f linter: move constant_identifier_names tests
Change-Id: I3bc6b00a94536c94ee0f68cc7875d6a05d9b76d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370420
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Sam Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-06-10 15:15:12 +00:00
pq 224d19ec06 [wildcards] avoid_unused_constructor_parameters wildcard test
Test to ensure that `avoid_unused_constructor_parameters` doesn't overreport in the presence of an unused wildcard param.

(Note that underscores are ignored pre-wildcards too and this ensures that that behavior is preserved too.)

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

Change-Id: I13ef73eb28cf2501ed292dd3c56c9933a8feefa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370540
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-06-10 15:00:00 +00:00
Sam Rawlins 38e60413a0 linter: move tests for three rules
* library_prefixes
* no_leading_underscores_for_library_prefixes
* package_prefixed_library_names

Change-Id: I641a547d572abc5001d42ceaed0dd216e0d07338
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370460
Auto-Submit: Sam Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-06-10 14:33:07 +00:00
Sam Rawlins 6c6b1040b4 linter: Allow each LintRule multiple categories
Spelled out at https://github.com/dart-lang/linter/issues/1020

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

This CL does not change the categories/groups that any rule has. We
can add/change categories in later CLs.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Ief2856a6c472492bbad19fc95df172ef8d19fe7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
2024-06-07 06:18:00 +00:00
Parker Lougheed 83135245b2 [linter] Publish new linter diagnostic messages
This CL doesn't set up the analyzer to surface links to these destinations, just includes the new format in the diagnostic messages file.

Change-Id: I6c227448b42a5abac53d5c6a863e599c7e8809da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Marya Belanger <mbelanger@google.com>
2024-06-05 22:07:03 +00:00
Sam Rawlins a75691fe7d linter: Remove unused fields in Group
Well, to be honest, remove all instances of Group. Instead, "groups"
are Strings. Because there was only one field left, a Group is just
a... name of a group.

Also, LintRule is no longer Comparable because that does not seem to
have served a purpose...

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I6e058139631dc1b06a4072a2549f156d1622c673
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369782
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-06-05 17:43:19 +00:00
Sam Rawlins 8e1ea1f114 linter: move always_put_required_named_parameters_first tests
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I5cdd56f3da7a70fdea2701f9a15f8dcd545f2462
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369766
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-06-05 16:28:20 +00:00
Sam Rawlins 149fc77208 linter: Remove a number of unused classes
* Remove unused LinterException, Reporter, PrintingReporter.
* Mark Hyperlink as visible-for-testing, and make 3 fields private.
* Make the LinterConstantEvaluationResult constructor private.
* Make LinterContextParsedImpl.package a getter

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Ib403fb7744e9454742d6555c8cdb8764ab4377be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369781
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-06-05 14:56:48 +00:00
Sam Rawlins 07fe01bf50 linter: Remove NodeLintRule from the hierarchy
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Id3c495ecd4b929114ee65be8e920cd5277d5291d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369524
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-06-05 04:18:58 +00:00
Sam Rawlins cf9a8bb532 analyzer: Move DartLinter to linter package's 'test_utilities'
And rename it to TestLinter.

We also get to remove `LintRule._locationInfo`,which was _only_ used
for testing pubspec-oriented rules.

This DartLinter class is only used in tests and tools of the linter
package, so it's good to move it out of analyzer lib/.

In order to remove `LintRule._locationInfo`, we move the singular
package_names test case to be a reflective test.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I97b5e79daa07eb3942f5444502473a4ec1e9daf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369562
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-06-04 17:13:49 +00:00
Sam Rawlins cc00e980f5 linter: Allow lint rules to specify afterLibrary actions
Add `NodeLintRegistry.afterLibrary` API which allows a lint rule to
register a callback to be called after the last CompilationUnit is
visited.

Change-Id: I77bf279412617e6f2c825b6dbeaf34849e515156
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368524
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-06-03 20:26:50 +00:00
Sam Rawlins 6e2ef10cde linter: Migrate avoid_implementing_value_types tests
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I8272cdf06e811344c1ec104f367eaf7bd578eb19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369340
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2024-06-03 15:54:00 +00:00
Sam Rawlins 42b262d0dd linter: Migrate avoid_classes_with_only_static_members tests
Change-Id: I82e92148c7b3f21db2a7e218cc6e0532b73a6f5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369260
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-06-03 15:46:39 +00:00
Konstantin Shcheglov 1b9cc28879 CQ. Make FileSource API, move to lib/source.
Change-Id: I981d3f0904917ada322ca06448f03ff33ae1f095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369360
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-06-03 00:36:59 +00:00
Konstantin Shcheglov d696014fe5 CQ. Stop using File.createSource() in analysis_server/.
This mixes layers, which I believe one of the ways that cause large
library cycles.

Change-Id: Id7124b9f4e4bf81838f637255fe04fd28f5fda01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-05-31 19:43:58 +00:00
Sam Rawlins 500a8c0a72 linter: Make some allowances in avoid_catches_without_on_clauses
Fixes https://github.com/dart-lang/linter/issues/3023

This fix is a little unusually large because I have to add some
elements to both the mock flutter package, and the mock SDK. This
affects some completion tests.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I44b68754f756cfe1cf99518957d74c4af56043f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-28 18:36:58 +00:00
Sam Rawlins 97d4d12dc0 meta: Add TargetKinds for @immutable; narrow error range for "invalid annotation" warnings.
This change looks big, and this is because we change the range of all
of the "INVALID_x_ANNOTATION" from the whole annotation (like
`@Immutable("...")`) to just the annotation identifier (like
`Immutable`). This affects many tests.

The error range is changed so that we can consistently use the
`RemoveAnnotation` fix to fix these warnings; it just needs a
consistent error node, so that it can find the Annotation node above.

All this to support `TargetKind`s for `@immutable`, so that we can
remove the custom "INVALID_IMMUTABLE_ANNOTATION" message.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Ifd64e154986b6cbcbafeb9420ca8d0949653e618
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367881
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-28 18:28:49 +00:00
Parker Lougheed 687a1d5a43 [linter] Fix formatting of noop_primitive_operations docs
Fixes https://github.com/dart-lang/site-www/issues/5867

Change-Id: I618199e38dfb524f0a4caeb2b01b498c63411064
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-05-28 14:47:36 +00:00
Sam Rawlins f07e042eaf linter: Fix avoid_types_on_closures for inference cases
Fixes https://github.com/dart-lang/linter/issues/1099
Fixes https://github.com/dart-lang/linter/issues/3330

We just add a check that the (approximate) context type is a function type.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I56fe14ff8852375754fdaf6b92b3c632b7df9c95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367982
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-25 05:28:39 +00:00
Parker Lougheed a768742545 [linter] Clarify that none can be specified to disable highlighting
Fixes https://github.com/dart-lang/site-www/issues/5861

Change-Id: Ic0dfdded5f38f1de4a19a7b41e52f87f3f9b9cef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368221
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-24 22:11:51 +00:00
Sam Rawlins 51f8b43696 linter: typos in use_build_context_synchronously
Fixes https://github.com/dart-lang/linter/issues/4979

Change-Id: I9692ccaf16b04a37071c16a9fdd172532916c86e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368120
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2024-05-24 16:24:30 +00:00
Brian Wilkerson 8c26c35950 Add documentation for more lints
Change-Id: I20955662d77591a0cd15f06de845008c3ffeaba1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364164
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-05-23 17:05:28 +00:00
Sam Rawlins 286715bda3 linter: Move no_literal_bool_comparisons tests
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I0a3831c2ba47ced728d9c71087e36e2c497fa1b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367141
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-05-22 18:43:58 +00:00
Danny Tuppeny 0f05924297 [analysis_server] Remove redundant solo_test tests
Checking for solo tests is now done as part of `verify_tests_test.dart` so solo tests currently produce two test failures.

This file did check one additional project that doesn't have `verify_tests_test.dart` does not (analyzer_cli) so it isn't exactly the same, but that project is going away (https://github.com/dart-lang/sdk/issues/48457) so it doesn't seem worth making `verify_tests_test` work there (there's a mismatch because it currently uses `all.dart` and not `test_all.dart`, but I suspect that filename may be coded into some bot configuration somewhere).

Change-Id: I7431ed0e141bab1898860f6fbe316833281d6fa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-05-22 16:34:31 +00:00
Sam Rawlins 022948c878 linter: convert path in test infra
Change-Id: Ie8c61aae0dc20be53c26741ef98f67f52c928bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367201
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2024-05-20 18:09:27 +00:00
Sam Rawlins 842a9820f0 linter: Move prefer_asserts_with_message test
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Ieada57f3d9b2974a8726c47fa526ba3baea8fc89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367161
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-05-20 17:06:41 +00:00
Sam Rawlins 5891bf0308 linter: move implicit_call_tearoff tests
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Idcfe32d68c120e9cb4848b71a6b54d0c5b157e7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367160
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-05-20 16:21:49 +00:00
Sam Rawlins 6413dd1178 linter: Fix duplicate reporting in unreachable_from_main in parts
Fixes https://github.com/dart-lang/linter/issues/4652

Change-Id: I4d80afd6424dc48fe7962c9b43e9815f2b79f60f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366969
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2024-05-20 15:43:53 +00:00
Parker Lougheed 10a38d0fd1 [linter] Update linter details for newest lints
Change-Id: If2ff9ea645c77cd4912f0bc6626468aa375b366e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366970
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-05-20 15:03:46 +00:00
Sam Rawlins bca7663025 analyzer: Offer lint rules the error reporter for each compilation unit
This primarily takes the form of adding an ErrorReporter field to
LinterContextUnit. In addition, we make the getter access to
`Linter.reporter` protected, to prevent lint rule authors from trying
to call `rule.reporter.reportError` with a temporary AnalysisError
that attempts to point to a specific source. The _setter_ for
`Linter.reporter` remains public, as it is generally set by the
framework.

Some other changes are made in order to facilitate this:

* Remove LinterAnalysis.linterUnit, no longer needed.
* Remove LinterContextUnit2, no longer needed.
* Correct the tests for avoid_private_typedef_functions and
  use_late_for_private_fields_and_variables. These tests did not
  correctly test declarations of typedefs or variables _in_ part
  files.

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

Change-Id: I77c14ab6e56f369417a27f5f5227d6ec11486c3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366405
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-05-17 21:23:59 +00:00
Sam Rawlins ee5eb9fedc Remove unnecessary Linter parent class, rename linterRegistry
Linter was in between LintRule and NodeLintRule, but the only subtype
was LintRule so the abstraction was unnecessary. There are lots of
small, nice follow-on effects across the codebase.

Also rename the top-level `lintRegistry` variable to be
`lintRuleTimers` as it is just a mapping of lint rule timers. (I was
confused about what this was because `Analyzer.registeredRules` is the
more general "registry of rules."

Also remove the deprecated, unused `getVisitor` API.

Also remove the unused top-level `linterVersion` string.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Icf75db7786fc2022e271ec6f32fd3aa00b2b4084
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366840
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-05-17 03:25:49 +00:00
Sam Rawlins 7c5437b8bf linter: Avoid infinite loop in avoid_redundant_argument_values
Fixes https://github.com/dart-lang/linter/issues/4970

Change-Id: I75e6fd554f12038acbd7604f52b2fe50d11a682d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366500
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-05-14 20:59:48 +00:00
pq 4f1e8d758d augmentation tests for unnecessary_getters_setters
See: https://github.com/dart-lang/linter/issues/4935


Change-Id: I8da7a111d86ea71338382a7c39558481c920cc37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-05-13 21:26:03 +00:00
pq b550c3fd0f update test to anticipate verifying augmentations
Change-Id: I9866d05f6a503e3a3b030d6c27173fe6aa61d9e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366064
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-13 19:05:54 +00:00
Sam Rawlins a9c2f1b6aa linter: move cast_nullable_to_non_nullable tests
Change-Id: I5bd5482108b9c0bb29936819ef4151d6b947a4b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366080
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-13 18:51:41 +00:00
Sam Rawlins f99bebc41a linter: Move camel_case_types tests
Change-Id: I106c2238f4ecb596809e195ef7b1f00cc47a95d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366061
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-05-13 17:23:09 +00:00
Sam Rawlins 5547884e33 linter: Handle more deferred cases in unnecessary_lambdas
Fixes https://github.com/dart-lang/linter/issues/2182

Change-Id: I975b4d1ae84245ff66d881a42ad7ca745569fab9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366060
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-13 17:16:17 +00:00
Alex Li ee43e8b61d [linter/flutter_style_todos] Only allow blank characters before TODO
R=brianwilkerson@google.com

Bug: https://github.com/dart-lang/linter/issues/3919

The flutter_style_todos rule recognizes characters before TODO, this PR removes that pattern recognition.

Change-Id: I328dccc44a656e5a3d983fc26491c49f2d3e5460
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363840
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Alex Li <alexv.525.li@gmail.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-05-13 03:29:19 +00:00
pq ba57b261e3 fix prefer_const_constructors_in_immutables test name typo
Change-Id: I542059488861857e3901f39e235b3e5cd8ce509b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366023
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-05-10 23:16:30 +00:00
pq 4d681b66de toList false negative test for avoid_redundant_argument_values
See: https://github.com/dart-lang/linter/issues/4967


Change-Id: I7dd892b8149b5a8562aab9eeb4e1fda256639110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365866
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-10 19:09:32 +00:00
pq a9905e98cf don't report prefer_const_constructors_in_immutables on macro constructors
Fixes: https://github.com/dart-lang/linter/issues/4966

Change-Id: I4aee65dc62df509833796100ca6f86b904fc72ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365860
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-05-10 18:55:23 +00:00
Sam Rawlins 5d4f700f7a Move LinterContext.resolveNameInScope to a utility function
This utility function is moved to the linter package, closer to the
two callers (two lint rules). The utility function takes with it,
the `LinterNameInScopeResolutionResult` class and
`_LinterNameInScopeResolutionResultState` enum. The implementation is
great, so it's not changed, and the existing API is good too.

Change-Id: I7809661e67ae38fd149466eea6bb45b1b632d7d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365663
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-10 15:15:52 +00:00
Sam Rawlins 607b3f5ddb linter: new rule for documenting ignore comments
In order to land this new rule, I add a new `IgnoredElement` subclass,
`IgnoredDiagnosticComment`, for any trailing comment text. This seems
like a pretty clean implementation. The text and offset are not used,
but it seems like it would be inconsistent to not offer them.

I also make a few IgnoreInfo fields private that are unused outside
the library.

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

Change-Id: Id6f949a317929dae8833e404d4c9f3c8e4f7bc90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365488
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-05-10 14:24:58 +00:00
Sam Rawlins a6762dd24c Report unsafe BuildContext access in Future.then and more
Fixes https://github.com/dart-lang/linter/issues/4923

In this change we now protect code inside callback arguments to
functions like `Future.then`. For example:

```dart
Future<int>.delayed(Duration(seconds: 1), (_) {
  return 42;
}).then((int value) {
 Navigator.of(context).pop();
});
```

In code like this, each reference to BuildContext must be guarded by
a mounted check.

There are a number of "protected functions" that the rule now checks:

Constructors:
* Future.new: 1st positional parameter
* Future.delayed: 2nd positional parameter
* Future.microtask: 1st positional parameter
* Stream.eventTransformed: 2nd positional parameter
* Stream.multi: 1st positional parameter
* Stream.periodic: 2nd positional parameter

* StreamController.new: 'onListen', 'onPause', 'onResume', and
  'onCancel' named parameters
* StreamController.broadcast: 'onListen' and 'onCancel' named
  parameters

Instance Methods:
* Future.catchError: first positional parameter, and 'test' named
  parameter
* Future.onError: 1st positional parameter, and 'test' named parameter
* Future.then: 1st positional parameter, and 'onError' named
  parameter
* Future.timeout: 'onTimeout' named parameter
* Future.whenComplete: 1st positional parameter
* Stream.any: 1st positional parameter
* Stream.asBroadcastStream: 'onListen' and 'onCancel' named parameters
* Stream.asyncExpand: 1st positional parameter
* Stream.asyncMap: 1st positional parameter
* Stream.distinct: 1st positional parameter
* Stream.expand: 1st positional parameter
* Stream.firstWhere: first positional parameter, and 'orElse' named
  parameter
* Stream.fold: second positional parameter
* Stream.forEach: 1st positional parameter
* Stream.handleError: 1st positional parameter, and 'test' named
  parameter
* Stream.lastWhere: 1st positional parameter, and 'orElse' named
  parameter
* Stream.listen: 1st positional parameter, and 'onError' and 'onDone'
  named parameters
* Stream.map: 1st positional parameter
* Stream.reduce: 1st positional parameter
* Stream.singleWhere: 1st positional parameter, and 'orElse' named
  parameter
* Stream.skipWhile: 1st positional parameter
* Stream.takeWhile: 1st positional parameter
* Stream.timeout: 'onTimeout' named parameter
* Stream.where: 1st positional parameter
* Stream.onData: 1st positional parameter
* Stream.onDone: 1st positional parameter
* Stream.onError: 1st positional parameter

Static Methods:
* Future.doWhile: 1st positional parameter
* Future.forEach: 2nd positional parameter
* Future.wait: 'cleanUp' named parameter



Change-Id: I703d5cfbee5e8af1f703f40046832d66b9b59bc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365541
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-10 14:16:41 +00:00
Sam Rawlins 4ead81a3fb linter: Skip rule message descriptions check on Windows
Change-Id: I11d7e9ec22fc6b2ac707240102d2cabfc6c64f4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365986
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-09 22:07:53 +00:00