Report unused public elements in an entrypoint library #58292
Labels
devexp-linter
Issues with the analyzer's support for the linter package
legacy-area-analyzer
Use area-devexp instead.
linter-lint-request
type-enhancement
A request for a change that isn't a bug
Describe the rule you'd like to see implemented
If a library has an entrypoint, I'd like to report any publicly accessible elements which are not used within the library as unused.
An entrypoint is a top-level
main
function, or a function annotated with@pragma(vm:entry-point)
. These files are typically:bin/
,web/
,tool/
,test/**/*_test.dart
,I think there will be very very few false positives. And perhaps any false positive indicates a code smell in library arrangement (the analyzer codebase I believe has some test files which reference another test file, each of which has a
main
).Any element which is not publicly visible should already be reported with analyzer's
unused_local_variable
,unused_element
, orunused_field
diagnostics. This lint would cover publicly visible elements:Examples
Additional context
This is an alternative route to #57580 and #57824.
The text was updated successfully, but these errors were encountered: