Skip to content

Conversation

@srawlins
Copy link
Member

Note: I'm not strongly suggesting this PR be accepted today as is. But I'm offering it up.

As part of the new analyzer plugin system, I'd like to offer some first-party-maintained analyzer plugins. I don't intend for us to maintain complex plugins necessarily. But good bang-for-our-buck plugins have some great benefits:

  • We provide examples of analyzer plugins for others to crib. This plugin clocks in at 160 lines of code, offering a static warning rule and a quick fix.
  • We provide value to customers of our first-party packages, like the test package.

If there are other static analyses that the team has dreamed of, I'd love to evaluate them for complexity and possibly add more static analyses to this plugin.

Again, we don't need to land this any time soon, if the team is hesitant to check this in, maintain it, etc. The new analyzer system is not officially released, and the API is probably not super stable. I'm opening this PR for the discussion, and to have URL to point to as a real world analyzer plugin example.

@github-actions
Copy link

github-actions bot commented Feb 25, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

@@ -0,0 +1,13 @@
# test_analyzer_plugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add something to the package:test readme as well, informing users of this plugin and how to enable it for their project.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are very "soft launching" analyzer plugins ATM, I think we don't want to advertise it there yet. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you I guess, but we won't get usage if we don't advertise it

@FMorschel
Copy link

FMorschel commented Nov 5, 2025

I've not yet read the whole changes, but what about an annotation on Matchers to specify what types we are expecting to handle and a diagnostic if they aren't being tested against them?

I'd love to contribute to it if this is something you are interested.

@srawlins
Copy link
Member Author

srawlins commented Nov 5, 2025

but what about an annotation on Matchers to specify what types we are expecting to handle and a diagnostic if they aren't being tested against them?

That's a fun idea, you could open an issue against this repo.

For first-party matchers in the matcher package, I don't think it would be worth the extra complexity. So the feature would be for custom matchers implemented outside of the matcher and test packages.

@srawlins srawlins force-pushed the test_analyzer_plugin branch from e6bd69d to 2635b72 Compare November 12, 2025 06:07
@srawlins
Copy link
Member Author

OK I'd love to land this actually. Esp with Dart 3.10 out today. Anyone know what the failing Publish check is about? I can't make heads or tails of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants