cobalt_lint 1.7.0
cobalt_lint: ^1.7.0 copied to clipboard
Analyzer plugin with lint rules for Cobalt. Catches invalid annotations in the IDE instead of at build time.
1.7.0 #
cobalt_read_does_not_match_registrationreports a read that always throws:get,getAsyncorcontext.cobalton a registration that takes a call-site value,getWithParamon one built asynchronously from it, andgetWithParamon one that takes none.
1.6.0 #
cobalt_dependency_is_not_registeredalso reports a dependency that only a child scope the class cannot see registers, naming that scope. Its quick fix moves a root class into the scope when exactly one registers the dependency:@cobaltInjectbecomes@CobaltInject(scope: Session).
1.5.0 #
cobalt_registration_is_not_generatedreports a registered class thatlib/cobalt.g.dartdoes not mention yet: it was annotated after the last build. Silent before the first build.cobalt_bloc_provider_closes_a_scoped_blocreportsBlocProvider(create:)handing out a bloc read from a scope, which closes it while the scope still holds it. Its quick fix rewrites the call toBlocProvider.value.- The values and
providesof a@CobaltChildScopecount as registered. Requirescobalt_analyzer1.5.0.
1.4.0 #
- The
cobalt_missing_injection_mixinquick fix also writes thepartdirective when the file does not have it. cobalt_dependency_is_not_registereddoes not report a constructor parameter with a default value. Requirescobalt_analyzer1.4.0.
1.3.0 #
cobalt_missing_injection_mixinasks a generic class forwith _$Cache<T>, and its quick fix writes the type parameters, or adds them to a barewith _$Cache.cobalt_dependency_is_not_registeredreports a dependency on an instantiation a generic class does not list:Store<Tag>when onlyinstantiations: [Store<Note>]registersStore. A generic class registered any other way is still matched by name. Requirescobalt_analyzer1.3.0.
1.2.0 #
- Quick fixes for seven rules, offered by the IDE on the diagnostic:
cobalt_injected_field_must_be_late_finaldeclares the fieldlate final,cobalt_missing_injection_mixinadds the_$ClassNamemixin,cobalt_injected_field_needs_an_injectable,cobalt_environment_needs_a_registrationandcobalt_param_needs_an_injectableadd@cobaltInject,cobalt_depends_on_lazy_registrationreplacesdependsOn: [...]withlazy: true, andcobalt_registration_is_never_releasedimplementsDisposableorAsyncDisposable. The README lists them. - The rules read a generic class as one registration per entry of
@CobaltInject(instantiations:), as the generator does. - Requires
cobalt_analyzer1.2.0. - The README opens with how to turn the plugin on and what it reports.
1.1.1 #
- No code changes in this package. Republished in lockstep with 1.1.1:
a shorter README with a Quick start,
examples/helloas the smallest app,docs/OVERVIEW.mdfor everything the README no longer holds, anddocs/TROUBLESHOOTING.md, one entry per error.
1.1.0 #
- No code changes in this package. Republished in lockstep with 1.1.0, which adds Korean to the inspector and to the documentation.
1.0.0 #
- The API is stable: from here on, only a major release breaks it — see Compatibility in the README. No code changes in this package since 0.9.0; coming from an older 0.x, MIGRATION lists what to change.
0.9.0 #
- New rule,
cobalt_hook_added_too_late:hookAllafter something that builds on the same scope — an eager registration,getand the other reads,init,warmUp— in an earlier section of the same cascade or an earlier statement of the same block on the same variable. The scope refuses it at runtime withCobaltHookError; the rule moves that into the editor. Eighteen rules.
0.8.0 #
- No code changes in this package. Republished in lockstep with 0.8.0, which
adds hooks on a supertype, makes every Cobalt error
final(breaking) and stops a log observer from formatting the records it drops — seecobalt's changelog.
0.7.0 #
- No code changes in this package. Republished in lockstep with 0.7.0, which
makes
CobaltResolvera base class (breaking), adds getters toCobaltRegistrationKindand lets the inspector open on a chosen tab — seecobalt's changelog.
0.6.0 #
- New rule,
cobalt_async_transient_read_synchronously:get,getOrNullorgetAllon aCobaltResolverorCobaltScope, orcontext.cobalt/cobaltAll, reading an async transient — which always throwsCobaltAsyncTransientError. The type argument may be written or inferred. Async transients only: a lazy async singleton is read withgetlegitimately oncegetAsyncorwarmUphas built it. Seventeen rules.
0.5.0 #
cobalt_lazy_registration_injected_synchronouslyandcobalt_depends_on_lazy_registrationsee async transients — a transient lifetime next to@CobaltInit, or on a module member returning aFuture— and their messages say so.cobalt_missing_injection_mixincovers@CobaltDecoratesclasses, andcobalt_injected_field_needs_an_injectableno longer reports them; a decorator's@injectedfields are edges of its target, so a loop through one is acobalt_dependency_cycle.
0.4.0 #
- The graph rules see decorators:
cobalt_dependency_is_not_registeredreports a decorator whose target or dependency nothing registers,cobalt_dependency_cyclea loop through a decorator, andcobalt_lazy_registration_injected_synchronouslya decorator taking a lazy registration. - An async class built from a call-site value may take a lazy dependency; the lazy rule no longer reports it.
0.3.0 #
cobalt_override_needs_type_argument: aCobaltOverrideorCobaltParamOverridewritten without its type argument, which Dart then infers asObjectinside a list or as the replacement's type on its own — either way the override replaces nothing.cobalt_depends_on_lazy_registration:@CobaltInit(dependsOn: [...])naming a lazy async registration, whichinit()never builds. Read from the package-wide index, like the other graph rules.- Sixteen rules.
- The package index no longer calls
Folder.getChildAssumingFolder, which analyzer 13.1 deprecated: under a fresh resolution the package itself faileddart analyze --fatal-infos.getChildexists and is current on every analyzer from 10 to 14.
0.2.1 #
- Accepts
analyzerup to 14.x (>=10.0.1 <15.0.0, was<13.0.0), so the plugin resolves for SDKs whoseanalysis_server_pluginneeds analyzer 13 or- Flutter 3.38.9 stays the floor.
- The registration index no longer names AST classes that exist on only one
side of analyzer 13 —
NamedExpression,DefaultFormalParameter,NormalFormalParameter— and reads tokens andchildEntitiesinstead. The rules report exactly what they did; every test passes on analyzer 10.0.1, 12.1.0, 13.3.0 and 14.4.0.
0.2.0 #
cobalt_lazy_registration_injected_synchronously: a lazy async registration taken by a synchronous or eager async constructor, or held in an@injectedfield on any class — what the build refuses since 0.2.0, reported in the editor. A lazy module member counts; a name two declarations claim does not.- The registration index read
@cobaltLazyInitas no registration at all, so a class depending on one was reported bycobalt_dependency_is_not_registered. It is read like@CobaltInit.
0.1.2 #
- No code changes in this package. Republished in lockstep with a
packaging fix in
cobalt0.1.2 (a stray file removed from its archive) — see its changelog. A fix in one package still ships as a patch for all fifteen, because publishing a subset is what lets the set drift.
0.1.1 #
- Fixed
cobalt_resource_is_never_closedreporting a false positive on any field that is itself another retained Cobalt registration — a singleton, lazy singleton, or async singleton the scope already disposes on its own, independently of who holds a reference to it. The rule checked only whether a field's type offers a teardown-shaped method, with no regard for whether the scope already owns and closes that field's value through a separate registration; on 0.1.0 this fired on the ordinary shape of a dependency graph — any class taking a closeable dependency by constructor injection — not only on the leak it was written to catch. A field of a transient or parameterized registration is still reported, because the scope never retains those and nobody else is going to close them.
0.1.0 #
-
cobalt_resource_is_never_closed: a registration that holds something closeable and offers no way to close it. -
Requires Dart
^3.10.0— Flutter 3.38 — instead of^3.13.0, and movesanalyzerto>=10.0.1 <13.0.0. The registration index was reading the analyzer 13 AST (FormalParameter.type,NamedArgument,Folder.getFolder,ClassBody.members); it now reads the model that spans the range. The old lower bound never compiled —Folder.getFolderarrived in 13.1, not 12.1. -
cobalt_param_needs_an_injectablereports@CobaltParamon a class nothing registers, where the marking does nothing at all. -
cobalt_dependency_is_not_registeredandcobalt_dependency_cycleskip@CobaltParamparameters, which nothing registers and which close no cycle. -
cobalt_injected_field_needs_an_injectablereports@injectedon a class the container never registers, where no mixin is generated andcobalt_missing_injection_mixinwould have sent you to a name that does not exist. That rule now stays quiet there. -
Initial release.
-
An
analysis_server_plugin(notcustom_lint, which is pinned to an incompatible analyzer) with nine warning rules, all reading annotations throughcobalt_analyzer— the same layer the generator uses. -
cobalt_dependency_is_not_registeredandcobalt_dependency_cycleanswer whole-package questions the analysis server does not offer a view for, from a shared syntactic index of what the package registers and what each registration asks for. Both match on bare names, so they stay silent where the build still objects; see the README for the cases and why they fall that way. The cycle rule additionally drops any name two declarations both claim, because fusing two same-named types is how a graph with no loop grows one. -
Rules cover: an injectable that cannot be constructed,
@injectedfields that are notlate final, a missing injection mixin,@CobaltInitwithout aninitmethod,@CobaltBootstrapwithout arunmethod, a bootstrap step taking injected parameters, and@CobaltEnvironmenton a class nothing registers. -
The analysis server resolves plugins from pub.dev rather than from your pubspec, so a
dependency_overrideinpubspec.yamldoes not affect which version loads. See the README for pointing it at local sources. -
The registration index reads
@CobaltModulemembers too, so a graph using modules does not produce false reports. -
cobalt_dependency_is_not_registeredskips optional dependencies. It walks them as a list rather than a set, becauseCobaltTypeRefcompares by signature and would otherwise foldFooandFoo?into one entry.