Commit Graph

33 Commits

Author SHA1 Message Date
Sam Rawlins 1692e68ccf Move AnalysisOptionsFile (yaml keys and values) out of validator file.
Change-Id: I978acaac38a502fbd97683d1dc3631617924d720
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443420
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-08-04 14:54:29 -07:00
Sam Rawlins 0ffd2849e4 analyzer: Move analysis options-validating code out of "task"
* OptionsValidator was defined in the `src/plugin/` directory (the only
  file in there), which I found confusing. Moved it to
  `src/analysis_options/`.
* OptionsFileValidator, and a few related classes, were defined in the
  `src/task/` (the last file in there!), so I moved it to the same
  place.

There is more to tidy in here, but this is a simple file-move.

Change-Id: I8f4c5cc0ae4e76eb6c17249457c50ab69c82590d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443147
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-07-31 15:05:31 -07:00
Sam Rawlins c219974ecf analyzer: Deprecate Diagnostic.errorCode in favor of diagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I2c7d64a81bc214e64fbc3ac95cf1fe2363a6ebd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433242
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-09 09:22:22 -07:00
Sam Rawlins 81ab0dab3c analyzer: Use Diagnostic instead of AnalysisError in lib/src
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Ifce5f4919f5bb8e12ac73994263d1a9fe745e0e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426402
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-04 12:29:51 -07:00
Sam Rawlins cfa4be3d93 analyzer: Use DiagnosticSeverity in analyzer packages
Work towards https://github.com/dart-lang/sdk/issues/60635

DiagnosticSeverity is the new name for ErrorSeverity.

Change-Id: I9d1040f23d4fe8affb234ff62527133e439adf50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-03 17:14:04 -07:00
Konstantin Shcheglov becd91df17 Format analyzer/ with tall mode.
Change-Id: I410cd1cf63fbf00b868bbb3e060433cad3ac9e6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-21 12:15:58 -07:00
Sam Rawlins 9e86286b66 Tidy up ErrorProcessor and AnalyzerConverter
Some of the parameters noted can be required and/or non-nullable as
per our internal usage, but this is all public API, so I'm just leaving
a note.

Mainly just simplify the implementation of ErrorProcessor.getProcessor.

Change-Id: Idebcf4a2485029c914d495cabfa3a1e98824c72c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396360
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-11-20 17:49:24 +00:00
Sam Rawlins 3f7df09ddb analyzer: Rename analysis options YAML keys variables
We rename `AnalyzerOptions` to `AnalysisFileOptions`, and change it's
comment from "`analyzer` analysis options constants." to avoid anyone
thinking it is specifying options for the `analyzer` section.

Additionally I privatize some of the static values that are only
present for validation - they are not meant to be used outside of
`options.dart`: `AnalyzerSection._trueOrFalse`,
`AnalyzerSection._options`, `AnalyzerSection._strongModeOptions`,
`AnalyzerSection._languageOptions`, `LinterSection._options`.

I also rename `_TopLevelAnalyzerOptionsValidator` to
`_AnalyzerTopLevelOptionsValidator` to align with
`_LinterTopLevelOptionsValidator`.

Change-Id: I4f5735d8bda8edbaf066387b473c05969c3ba7d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395060
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-15 21:41:29 +00:00
Sam Rawlins 3518e02573 analyzer: Make strict modes part of AnalysisOptions API
I think when I was adding these modes, I put them on AnalysisOptionsImpl
to keep them secret and flexible. But they're pretty stable now.

Also split out the analysis options `include` tests to test merging
of individual lists and maps.

Change-Id: Ie54a1951dc82900c1fdfc06023cfa7cfb2f410a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391020
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-21 15:48:05 +00:00
Sam Rawlins d07ab77881 analyzer: Simplify ErrorConfig
Normally I'm all in favor of breaking up methods to improve readability,
especially to reduce indentation. But I was able to inline `_process`
and `_toSeverity`, and stop relying on `utilities_general.dart` and
keep the code with minimal indentation.

Change-Id: I1e0fe3be4b135de15400f9d2c854c21ae5f47240
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389041
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-10 22:43:20 +00:00
Sam Rawlins f8c6f2135d [analyzer] Remove many instances of the word 'hint'
I took care to leave code and comments which _does still_ refer to the
remaining Hints. This CL is not super complete, but I think addresses
most of the outdated text refering to Hints. I will do another round
after migrating more to Warnings.

Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: Iab58dbbfbdef86e21dd65b2a96d8e34e3e7e54ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-03-23 03:59:55 +00:00
Sam Rawlins 105efd85b6 [analyzer] Add a valueOrThrow extension similar to our oft-used typeOrThrow
This really helps in complying with strict-casts. YamlNode.value returns
a `dynamic`, which is then often passed somewhere which accepts Object
(and then does some type tests). To avoid the implicit cast from
`dynamic`, we can use `.valueOrThrow` (or basically just
`.value as Object`).

The extension getter improves readability and avoids a lot of
as-expressions inside conditional expressions etc.

Change-Id: I50d2eebd51d6fc3eccf1c930652dd5ce70dd9eb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277582
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-01-03 18:53:39 +00:00
Konstantin Shcheglov 9f986d2501 Migrate package:analyzer to null safety.
Change-Id: Iffe4370431587e46a141ddc72a86ceec29c163b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176486
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-02-01 18:56:04 +00:00
Konstantin Shcheglov 54b7543c55 Fix unnecessary_const in analyzer.
The only non-mechanical change is update for tool/diagnostics/generate.dart
to handle MethodInvocation, because without resolution and without
explicit `new` and `const` we get MethodInvocation(s).

R=brianwilkerson@google.com

Change-Id: Ib89ce9c37066e9b27ad03aed96b349ef36f11d43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127453
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-06 15:03:00 +00:00
Konstantin Shcheglov 364dd8936b Fix unnecessary_new in analyzer.
R=brianwilkerson@google.com

Change-Id: I70f80baa3da4b14c0a52c1f28da16a9ad26d7dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127424
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-12-06 01:11:30 +00:00
Brian Wilkerson 5f0de26d48 Clean up the remaining copyright notices
Change-Id: If099be4f71ba551df0dc3d69815ae6a9f55d1eba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97781
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-03-24 20:11:28 +00:00
Konstantin Shcheglov 1ba59eb13d Make ERROR the default severity for StaticWarningCode. Remove _StrongModeTypeErrorProcessor.
As a preparatory step for re-landing https://dart-review.googlesource.com/c/sdk/+/91170
and making these two restored problems to warnings.

R=brianwilkerson@google.com, paulberry@google.com

Change-Id: I6266632ade84743b5725c54475fe402902576c00
Reviewed-on: https://dart-review.googlesource.com/c/91420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-01-28 22:08:17 +00:00
Konstantin Shcheglov 2ede4c7543 Downgrade WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR to warning.
Per https://github.com/dart-lang/sdk/issues/34403#issuecomment-420465838
request.

R=brianwilkerson@google.com

Change-Id: I9a2c319d2262aacf14bfc180d59d16db3f199a2a
Reviewed-on: https://dart-review.googlesource.com/74560
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-09-12 19:11:26 +00:00
Konstantin Shcheglov 02b2deefd6 Remove StaticWarningCode.isStrongModeError flag.
It is not used internally outside Analyzer itself.

R=brianwilkerson@google.com, paulberry@google.com

Change-Id: Iec2b45ebaeb49400e9f61a137a85170657856016
Reviewed-on: https://dart-review.googlesource.com/72300
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2018-08-31 01:19:24 +00:00
Brian Wilkerson ab1c1582b1 Remove deprecation hints in analyzer packages
Change-Id: I001e57239a87f2806be74052a5e7686245fea812
Reviewed-on: https://dart-review.googlesource.com/65000
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2018-07-17 15:22:07 +00:00
Brian Wilkerson 26c06cdd82 Clean up Dart 2 type issues related to YAML support
Change-Id: Ic29054afca9773286aa899eecede287f7ecbca9a
Reviewed-on: https://dart-review.googlesource.com/47680
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-22 17:06:40 +00:00
Devon Carew 796baf6f16 Fix an issue with configuring the severity of lints.
BUG=
R=brianwilkerson@google.com, pquitslund@google.com

Review-Url: https://codereview.chromium.org/2863013002 .
2017-05-05 13:17:04 -07:00
Konstantin Shcheglov 132eb40cb6 Issue 28466. Include ErrorProcessor(s) into the AnalysisOptions signature.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/28466

Review-Url: https://codereview.chromium.org/2651513002 .
2017-01-22 13:22:20 -08:00
Konstantin Shcheglov 0728e4ee70 Implement 'analysis.getErrors' for the new driver.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2566013002 .
2016-12-11 15:27:57 -08:00
Brian Wilkerson e63105555b Remove uses of configuration data
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2522543007 .
2016-11-22 11:26:08 -08:00
Brian Wilkerson ecc84b26a4 Break up another large file
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2342733002 .
2016-09-15 07:49:27 -07:00
John Messerly 1b9bf0769d fix #26122, classify strong mode errors correctly
StaticTypeWarningCode was being handled, but many warnings with StaticWarningCode also need to be treated as errors.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2108823002 .
2016-06-28 14:35:44 -07:00
Brian Wilkerson 3024554b3c Improve type information and minor clean up
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1977413002 .
2016-05-16 08:43:58 -07:00
Brian Wilkerson 5309d86424 First batch of changes to make analyzer package strong mode error free
Review URL: https://codereview.chromium.org/1808123005 .
2016-03-18 07:47:58 -07:00
Bob Nystrom a602585097 Don't upgrade the severity of *everything* to an error in strong mode.
Oops!

Fixes #26026.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1813973002 .
2016-03-17 12:58:18 -07:00
Bob Nystrom 2ef00b0c3d Don't report redundant type errors in strong mode.
Currently, "sideways casts" -- type errors where one type is assigned
to an unrelated type -- are reported by both ErrorVerifier and strong
mode's Checker. This leads to duplicate errors that the user can see.

ErrorVerifier's errors are generally better: they give the user more
contextual information and are easier to read. So this CL eliminates
Checker's reporting of these errors and only uses ErrorVerifier's.

However, in strong mode, type errors like this are fatal: DDC can't
generate correct code. So this also automatically upgrades all static
type warnings to errors when strong mode is enabled.

R=brianwilkerson@google.com, leafp@google.com

Review URL: https://codereview.chromium.org/1780783002 .
2016-03-15 12:14:11 -07:00
pq 34780784f2 Error code validation updates.
Updates validation to handle configured severities (`error`, `info`, and `warning`).

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1541453002 .
2015-12-18 12:58:25 -08:00
pq 62656833d4 Wraps up the server-side of the 'Allow a user to configure which hints are "fatal"' ask (#24452).
* migrates error filtering from a predicate to a process that can customize severities.
* moves filtering/processing from the `dart` task into the `getErrors` request and the errors notification.

See: https://github.com/dart-lang/sdk/issues/24452

(Pending a thumbs-up, support for CLI to follow.)

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1517723002 .
2015-12-10 13:35:11 -08:00