Commit Graph

147 Commits

Author SHA1 Message Date
Sam Rawlins 2dc94ee84a analyzer: Rename DiagnosticCode.errorSeverity to DiagnosticCode.severity
Change-Id: I244a96a940f82902a20e817fd13fe32026607ce3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430581
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-22 17:25:01 -07:00
Sam Rawlins e4810025ad Remove RuleState type hierarchy with an enum and condensed constructors
Change-Id: I07ee606b00467b8113f1722dba21b8c16cfe85b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 09:53:18 -07:00
Sam Rawlins 4ef189a513 linter: Rename State to RuleState, and sub-classes
Change-Id: Id74c1a34e0a3154e1720d323bf4002aceb092dd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-20 15:52:54 -07:00
Parker Lougheed 640d9a760f [linter] Update lint changelog for 3.8 and 3.9
Also mark recently published lint docs as published.

Change-Id: If2fba38b6c6cae5764691803d9359dffca8ddf33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429281
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-19 14:54:26 -07:00
Sam Rawlins aa5f130ce8 linter: Remove analyzer impl export
This reduce's linter's exposure of private analyzer API, which will
help with making LintRule public API.

Change-Id: I5af1961cf6e7e6c8554962d055a2f311256e3895
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428901
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-16 07:14:11 -07:00
Sam Rawlins 22453ba77f linter: deprecate AnalysisRule.lintCode
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: Iedf1127b9f04aec910647c7f35597f38c6bfe1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428846
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-15 16:20:11 -07:00
Konstantin Shcheglov 05da3e1f22 Elements. Deprecate Element.enclosingElement2, use enclosingElement.
Change-Id: I055b1f9dd1c00605d813effcbbadb9cea874129a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 13:47:32 -07:00
Sam Rawlins a3b1b4f172 analyzer: Deprecate AbstractAnalysisRule.lintCodes
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I4c86dbf806964c98f4a1c5854eb53c6c8cfe002b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428624
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 11:04:43 -07:00
Sam Rawlins 77d673c841 linter: Reduce usage of InheritanceManager3
Change-Id: Ifb33d26de1223a575cf29b7904f1cf1269f4a3e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428063
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-13 09:47:11 -07:00
Sam Rawlins aebc7fd74c analyzer: Tidy up Spelunker API
Work towards https://github.com/dart-lang/sdk/issues/55660

Spelunker will move to the analyzer_testing package, so we must first
clean it up.

Spelunker had two subclasses, but their only differentiation was the
calculation of a getter, which could be a final field. So I remove the
subclasses, move the "File"-based one to the spelunk utility script,
and change the Spelunker constructor to take in a source string.
Additionally:

* Make all of the fields private.
* Remove isDartFileName and isPubspecFileName. These calculations can
  be inlined into their call sites and make use of the `file_paths`
  library.

Change-Id: I4b97ed03a2845440dabd3a9ab0aa3b3ba4af5959
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428083
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-12 14:10:20 -07:00
Sam Rawlins abd4e7754c Introduce two subclasses of 'LintRule' for handling multiple lint codes
Before this change, we had an enforcement that either 'get lintCode' or
'get lintCodes' is implemented, but it was a runtime enforcement. And it
was a little roundabout.

The new system is simpler and more typical:
* `AbstractLintRule` is the parent type, and it's sealed. It provides
  `get lintCodes` as an interface. Code outside of the lint rules
  requires this getter, in registering codes, etc.
* `LintRule` is the new subclass which is the "90% case." It declares
  a `get lintRule`, and offers simpler reporting methods for reporting
  a single code everywhere.
* `MultiLintRule` is the new subclass which represents that last
  "10% case." It only declares the reporting methods which all require
  a LintCode parameter, since there is no concept of a "default lint
  code among all my lint codes."

Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I63cbbfc1d936bb4428aa0b8f5fb0638c9b61b3dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426284
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-08 16:10:57 -07:00
Sam Rawlins 8aa021f31e linter: Use Diagnostic instead of deprecated AnalysisError
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I225bcbe2c0033872b0349258f7f2135aab6a8d20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426561
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-05 15:44:14 -07:00
Sam Rawlins a06be8f7bf linter: Migrate reportLint to reportAtNode for rules q-z
Change-Id: Idc5711338e0cae4232d680634d8b85a7c57fbad0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-30 07:55:18 -07:00
Konstantin Shcheglov b2fdd8a345 Elements. Rename XyzElement2 into XyzElement.
The CL was done with rename + adding typedef for each class.

Change-Id: Ia25cc581d2e42cf7d12a85a3579af952d5c232ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424687
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-25 13:27:18 -07:00
Sam Rawlins 6f2d732032 analyzer: deprecate reportLintForToken; migrate all SDK callers
Change-Id: I23c5d3d3f7ee1657f17b3d507e1d4edf1afd65d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424701
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-04-25 12:42:30 -07:00
Konstantin Shcheglov 49599e06cc Elements. Deprecated element2.dart library.
Change-Id: I2be38df49e6f242d9fe59f34164549da4a0f41b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424683
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-25 11:23:18 -07:00
Parker Lougheed 89593b3a98 [linter] Remove unused tools
These tools aren't relevant anymore or no longer work.

Change-Id: I133cc5b97f7a9d568ba70a1de4e4fca50f3c58a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-09 07:18:49 -07:00
Danny Tuppeny 22e3e969b3 [analysis_server] [linter] Fix some additional tests when running through the test runner
`Platform.script` doesn't work when run through `dart test` (see https://github.com/dart-lang/test/issues/110). This uses `Isolate.resolvePackageUriSync` to locate package roots instead.

Change-Id: Ieda05cd625cf07152d695daf94c99f1fad1cefe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-04-01 14:59:19 -07:00
Parker Lougheed 2b8c0ee20a [analyzer] Mark latest diagnostic docs as published
Change-Id: I288dcf8c997819bc2e48bf7b4479c37dcba35485
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419681
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-04-01 10:51:19 -07:00
Sam Rawlins ab909226e3 analyzer: simplify updateAnalysisOptions parameter signature
Currently, the `AnalysisContextCollectionImpl` constructor has a
callback parameter, `updateAnalysisOptions2`, which has 3 required
parameters. The caller can then pass in a closure which accepts those
parameters, and updates analysis options.

I find this to be a bit of an awkward API, and a little bit complex, so
it would be good if we can simplify it. It is all private impl, but it
is used in a few codebases, I believe. Dartdoc is one.

So, it looked to me like none of the callers _use_ the `ContextRoot`
parameter, so it would be good to simplify here, and remove it from
the callback signature.

This is _not_ the final API I'm looking for. Just an incremental step,
and since it is private API, it doesn't need to be in a major release
of analyzer.

Change-Id: Iad9da9f36e817add0bd8c49975ecd14311588661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392204
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-03-24 10:31:23 -07:00
Parker Lougheed 6322a400f1 [analyzer] Update messages and lint docs for downstream status
Change-Id: Ie4e057956dba0e568fa7fa6497ce42922207a382
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414440
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-07 17:37:20 -08:00
Parker Lougheed 2e13d4d954 [linter] Doc and changelog updates
Change-Id: I64554034fc510afdab1c3e1dab18a3855fd31b09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406782
Commit-Queue: Marya Belanger <mbelanger@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
2025-02-03 15:08:15 -08:00
Mohamed Abdelaal 9b7bb9df90 Fix "the the" typo
Closes https://github.com/dart-lang/sdk/pull/59926

GitOrigin-RevId: cb37bca473b0c177b876a0f4e75858cd1862e699
Change-Id: I6827241b22e99db455945afcdfbaee0450999ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404923
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-01-21 14:08:20 -08:00
Sam Rawlins 927769e9f3 linter: Simplify lint rule selection
Just a little nit; it took me a second to figure out what was going on
with the `add` tearoff.

Change-Id: I96a59ea9fe513fa28894c0cb41ede7a07dbb18b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404521
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-01-15 10:13:51 -08:00
pq c988e32a56 [cq] remove unnecessary ignores
See: https://github.com/dart-lang/sdk/issues/35234

Change-Id: I4563df48df9d71332b3de6fabea9176e199c1ad5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404202
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-01-13 15:05:28 -08:00
pq 02483247a7 [cq] bump linter to 3.7 and tall-style format
Change-Id: I08e8310c6133418fd99954c306601b277a85f3c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403932
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-01-13 12:46:50 -08:00
Parker Lougheed fec029fa04 [analyzer] Mark latest lint and diagnostic docs as published
Also fixes a few minor typos.

Change-Id: I026bb91682440aa851f05f998c4c67c3d1a7a56e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403540
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
2025-01-07 18:12:37 -08:00
Devon Carew 79b52401f2 Update various packages based on diagnostics from strict_top_level_inference.
Change-Id: I032d10fd1956b62a9e45ceee9ca2b28c9863d1ce
Tested: diagnostic updates only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401560
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2024-12-19 08:23:51 -08:00
Sam Rawlins f11466be99 linter: Remove infra for removed integration-style tests
Change-Id: I0e8d4db0914fb72d451f7fbea389e0bf8cd36886
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399625
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-12-10 00:12:59 +00:00
Parker Lougheed 7ecf333dcf [linter] Mark package_api_docs as removed
Resolves https://github.com/dart-lang/sdk/issues/59554

Change-Id: Ic843c827b1b7c9345132c4b8d901de040a56e1a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396780
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-12-05 21:43:19 +00:00
Konstantin Shcheglov 8eb24f0724 Elements. Make 'get library2' non-nullable in more places.
Change-Id: I0f9a27ce61367826fb1a1af3969cef0014639a31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-12-04 20:13:12 +00:00
Erik Ernst e88f0811f9 Shortened the documentation of unsafe_variance
It is now 69 lines, and not the longest.

Change-Id: Ibf618c2356f0bcf90ab3a4f5661a094f53382b22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395523
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-29 14:36:49 +00:00
Parker Lougheed 9de2a62d74 [linter] Store historical state in messages file
Follow-up PRs will have linter rules use a generated version of these, removing the current duplication.

Contributes to https://github.com/dart-lang/sdk/issues/56835

Change-Id: Ie7a7225001cc254b2ea1428d2f21c5ba1db5ba52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396920
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-21 22:15:19 +00:00
Erik Ernst 7b71ed17b2 Introduce the lint unsafe_variance
This CL implements a new lint, `unsafe_variance`. This lint emits a
warning whenever an instance member declaration has a signature where
a type variable declared by the enclosing class/mixin/enum occurs in
a non-covariant position in the return type (including the type of
an instance variable).

Issues: https://github.com/dart-lang/linter/issues/4111, with goals related to https://github.com/dart-lang/language/issues/296 and https://github.com/dart-lang/language/issues/524.

Change-Id: I1352d71d61fece03a432ccf0d98825a69e3a457f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384700
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-11-15 09:28:52 +00:00
Erik Ernst c9391d7f19 Set obvious/property lints to hasFix
The lints `omit_obvious_property_types` and
`specify_nonobvious_property_types` previously had error fix status
'needsEvaluation'. This CL changes it to 'hasFix'. This is needed in
order to get access to the fix in IntelliJ.

This CL also corrects a bug whereby a map literal was considered to have an obvious type in cases where there were no actual type arguments and no elements with an obvious type.

Change-Id: Id9305152d086604b78636b696bd97e318ed6bdb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393280
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-09 16:59:49 +00:00
Sam Rawlins cb5c73e06f linter: Remove unsafe_html rule
Fixes https://github.com/dart-lang/linter/issues/5001

Change-Id: I972ea8f9fafda88b6a4836ab92107cebe8a6ad4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391303
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-11-08 18:31:59 +00:00
Parker Lougheed 2de5bb15f1 [linter] Changelog and since updates for 3.6 and 3.7
Change-Id: Ic308308ee7590a3dc10d84b4b33fa78ae4135a11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393587
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-06 17:10:52 +00:00
pq c84515f419 [element model] migrate tool to opt-out semantics
See: https://dart-review.googlesource.com/c/sdk/+/393482

Change-Id: I08fc376892652699d1eed674d8267851e2c3a02b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393483
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-04 22:49:20 +00:00
Sam Rawlins e33fad2eb0 linter: Simplify formatter hierarchy
Previously there was a `ReportFormatter` -> `SimpleFormatter`
-> `DetailedFormatter` hierarchy, but `DetailedFormatter` was the only class that was concretely instantiated. So we collapse these three
into one class. (`SimpleFormatter` was used in tests, but here we
convert those uses to use the remaining `ReportFormatter` class, and
use the `test_descriptor` package to allow that formatter to read
source files from disk, during the test.

Additionally, no arguments were passed for the `fileCount`, `fileRoot`,
or `machineOutput` constructor parameters, so those parameters and
corresponding fields are deleted.

Change-Id: I9d14acef7379325c42dcc729b9c77362ccd1aa86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392408
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-04 20:57:09 +00:00
Sam Rawlins 784af8f704 DAS plugins: track lint rule configuration by name
* PluginConfiguration.ruleConfigs is now a Map instead of a List,
  mapping analysis rule names to each RuleConfig. This makes it more
  straightforward (and theoretically more performant) for the Registry
  to determine the set of enabled analysis rules. The primary parsing
  code, `parseLinterSection`, also returns a mapping now.
* This merges seamlessly into `AnalysisOptionsImpl`'s call to
  `parseLinterSection`.

This is most of the refactoring work found in
https://dart-review.googlesource.com/c/sdk/+/392981, but without the
change to allow warnings to be disabled.

Change-Id: I4d1e6791da83ad370c18a15e9e3bb85b1daed58d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-01 16:28:30 +00:00
Sam Rawlins 1db40b6eb8 analyzer: Add an AnalysisRule alias for LintRule
Since the LintRule class is the basis for writing both "lint rules"
(rules that must be explicitly enabled) and "warning rules" (rules that
are enabled by default), it is a misnomer to use 'LintRule' as a
supertype. This change adds an alias, 'AnalysisRule'. Additionally:

* Rename LinterVisitor to AnalysisRuleVisitor.
* Rename lintRuleTimers to AnalysisRuleTimers.
* Rename LinterExceptionHandler to AnalysisRuleExceptionHandler.
* Rename LintRuleExceptionHandler to _AnalysisRuleExceptionHandler.

* NodeLintRegistry is used in too many places, so I have left it for
  now.

Change-Id: I43340cca0f9b64502960d8f5e05c6c9b81c3dfd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392203
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-30 17:43:19 +00:00
Sam Rawlins 437bcb89cb linter: Remove under-used Analyzer class
Change-Id: I2a5aa6a17355249f8de9d013efc6adea4be7d949
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392320
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-29 21:33:28 +00:00
Sam Rawlins 16b1b5c450 analyzer: Move LinterOptions to the linter package test utilities
Change-Id: I525132a98f2d2a683150393b22ee66b002a4d507
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392244
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-29 16:36:21 +00:00
Sam Rawlins 4cb5274108 analyzer: Move AnalysisErrorInfo into the linter test utilities
Change-Id: If6115cd0d3ffe4416f13567b79c835d0ab90bc79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392280
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-29 16:04:59 +00:00
Sam Rawlins bc58f69e53 analyzer: Move AnalysisOptionsImpl out of the generated directory
None of the code in AnalysisOptionsImpl or AnalysisOptionsBuilder is
changed.

Change-Id: I0d3253d80fdcd624c73720c35ece9d23a2582071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392180
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-28 21:03:33 +00:00
Sam Rawlins 155a64c1b7 DAS plugins: Allow plugin rules to be disabled by default
This bumps the Registry class to be able to take "rules that are enabled  by default" and "rules that need to be explicitly enabled", "lint rules" and "warning rules". Next is to improve the classes.

Add parsing for the top-level `plugins` section, and
`PluginConfiguration` class to hold this data, and
`get pluginConfigurations` on AnalysisOptions.

Rename `parseLintRuleConfigs` to `parseLinterSection` to align better
with the other functions in engine.dart.

Rename `_ruleConfigs` function to `parseRulesSection`.

Change-Id: Ib93b7548bfb13cc94381971a5a2780a5dc81e9f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-28 01:42:02 +00:00
Sam Rawlins 03d7cc4ed6 analyzer: Remove internal LintConfig class; static elements can be top-level.
This just simplifies the internal parsing code that parses out lint rule
configurations from YAML.

Change-Id: I7eb83835cff25f99b79dad9446db5215dce126fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391700
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-23 21:23:50 +00:00
Konstantin Shcheglov 3af9430ebf Elements. Separate Element2.name from Element.name by renaming to 'name3'.
They were intersecting at ElementImpl and Member(s).

This will unblock updating implementations to make them nullable.

Change-Id: Ic9907eaa0ef08c096839f212668fa1e3d92bbf3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-23 15:53:40 +00:00
Sam Rawlins 2fd0b1aac4 linter: extract ruleConfigs earlier
Each call site for `parseLintRuleConfigs`, `processAnalysisOptionsFile`
immediately just want the `ruleConfigs` (which is the only property of a
LintConfig). So instead of passing around LintConfigs, just pass around
the list of RuleConfigs.

(LintConfig can probably be deleted now, but I'll look at that for a
separate change; might need care with google3.)

Change-Id: I30eba648e5f53bc5d5196ce95c09c8261535a737
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391161
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-21 23:32:22 +00:00
Parker Lougheed 47ecb53072 [linter] Mark unnecessary_final and prefer_final_in_for_each as incompatible
Change-Id: Ifa4af7c5ab4c5e68ae3e71bc6fc6a3b30394927b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391022
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-21 16:59:06 +00:00