registerAsyncJobLints function

void registerAsyncJobLints(
  1. PluginRegistry registry, {
  2. bool ownQueueReportedElsewhere = false,
  3. bool ownLaneReportedElsewhere = false,
})

Registers the rules of async_job_lints and their quick fixes in registry.

With ownQueueReportedElsewhere, bare_await stays quiet on a wait for a job of the controller's own queue, because a rule of the calling plugin reports that wait. Without it bare_await reports the wait as any other.

With ownLaneReportedElsewhere, bare_await and discarded_outcome stay quiet on a wait in a job body of a SoloLanes for a job of the lane that body runs in, for the same reason. A plugin that does not report such a wait leaves it to them.

Implementation

void registerAsyncJobLints(
  PluginRegistry registry, {
  bool ownQueueReportedElsewhere = false,
  bool ownLaneReportedElsewhere = false,
}) {
  registry
    ..registerWarningRule(CtxInCleanup())
    ..registerWarningRule(
      DiscardedOutcome(ownLaneReportedElsewhere: ownLaneReportedElsewhere),
    )
    ..registerWarningRule(OutcomeAfterAwait())
    ..registerWarningRule(ReleaseOnTheCall())
    ..registerFixForRule(ReleaseOnTheCall.code, PassReleaseToCall.new)
    ..registerWarningRule(SyncFakeAsync())
    ..registerLintRule(CatchWithoutCheck())
    ..registerFixForRule(CatchWithoutCheck.code, AddCheck.new)
    ..registerLintRule(
      BareAwait(
        ownQueueReportedElsewhere: ownQueueReportedElsewhere,
        ownLaneReportedElsewhere: ownLaneReportedElsewhere,
      ),
    );
}