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>
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>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>