KogenCredo.CoreSupport.Settings (KogenCredo v0.1.0)

View Source

Strict parameter validation for checks.

A mistyped threshold ("400"), a bare string where a path list is expected or a module given as a string must stop the run with an ArgumentError; silently treating it as "nothing configured" would look like a green run.

Summary

Functions

Requires a list of atoms (modules or names).

Fetches key and requires an integer >= min.

Requires a keyword list or map with only the allowed keys.

The name of one module reference given as an atom (MyApp.Codec, :ets) or as a string ("MyApp.Codec", "Elixir.MyApp.Codec", ":ets"), or nil when it is neither. For helpers that take either form; check parameters go through modules!/2.

Requires a list of module atoms (MyApp.Codec, :ets) and returns their names.

Requires a list of binaries.

Functions

atoms!(value, key)

@spec atoms!(term(), atom()) :: [atom()]

Requires a list of atoms (modules or names).

integer!(value, key, min \\ 0)

@spec integer!(term(), atom(), integer()) :: integer()

Fetches key and requires an integer >= min.

known_keys!(entry, allowed, what)

@spec known_keys!(term(), [atom()], String.t()) :: term()

Requires a keyword list or map with only the allowed keys.

module_name(atom)

@spec module_name(term()) :: KogenCredo.CoreSupport.Ast.module_name() | nil

The name of one module reference given as an atom (MyApp.Codec, :ets) or as a string ("MyApp.Codec", "Elixir.MyApp.Codec", ":ets"), or nil when it is neither. For helpers that take either form; check parameters go through modules!/2.

modules!(value, key)

@spec modules!(term(), atom()) :: [KogenCredo.CoreSupport.Ast.module_name()]

Requires a list of module atoms (MyApp.Codec, :ets) and returns their names.

Configuration names modules with atoms, and a string is still rejected (a mistyped list must not look like "nothing configured"). The atoms are only read: they come from the config, never from the analysed code, and the result is compared by name (see t:Ast.module_name/0).

raise_bad(key, value, expected)

@spec raise_bad(atom(), term(), String.t()) :: no_return()

strings!(value, key)

@spec strings!(term(), atom()) :: [String.t()]

Requires a list of binaries.