CredoHotUpgrades.Check.ClosureInOptions (CredoHotUpgrades v1.0.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of high and works with any version of Elixir.

Explanation

An anonymous function, or a capture of a local function, is tied to the version of the module that built it. Once that module is replaced the value is dead, and calling it raises BadFunctionError.

The same rule reaches past state, ETS and messages into anything a library keeps and calls back into later. A child specification is kept by its supervisor and used again at every restart: {Task, fn -> warm_cache() end} fails on the restart after the module that built the fn is replaced. A connection pool keeps configure: and after_connect: the same way, a Telemetry.Metrics reporter keeps measurement:, tag_values:, keep: and drop:, and :ssl keeps sni_fun: and verify_fun:.

Pass {MyApp.Cache, :warm, []} or a capture of an exported function wherever a library asks for one of these, not an inline fn.

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.