KogenCredo.Check.Warning.CtxBag (KogenCredo v0.1.0)
View SourceBasics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
Pass the values a function needs (root, now, a %Project{}), not a bag of
services. A bag hides what a function depends on and lets every function reach
every capability. Effects that tests replace belong behind a behaviour chosen at
compile time.
Triggers: a parameter named like a bag (banned_names) used in several clauses,
or a parameter that is threaded through most clauses while the file reads many
distinct (and service-like) fields from it. Struct-typed parameters are exempt.
Check-Specific Parameters
Use the following parameters to configure this check:
:banned_names
Parameter names reported when used in min_named_clauses clauses.
This parameter defaults to [:ctx, :context].
:allowed_names
Parameter names never reported.
This parameter defaults to [:conn, :socket].
:min_named_clauses
Clauses a banned name must appear in.
This parameter defaults to 3.
:min_clauses
Clauses a parameter must appear in for the structural trigger.
This parameter defaults to 4.
:min_passed_ratio
Share of those clauses that pass the parameter to another call.
This parameter defaults to 0.5.
:min_fields
Distinct fields/keys read from the parameter.
This parameter defaults to 8.
:min_ambient
How many read fields must be ambient/service-like or called as functions.
This parameter defaults to 2.
:ambient_fields
Field names that look like injected services or ambient state.
This parameter defaults to [:root, :cwd, :dir, :env, :tmp_dir, :tmp, :now, :clock, :time, :runner, :proc, :cmd, :git, :io, :shell, :config, :opts, :options, :log, :log_path, :logger, :harness, :provider, :http, :client, :repo, :timeout, :deadline, :registry, :store, :cache, :runtime, :deps, :services].
:included_paths
Only files under these path prefixes are checked.
This parameter defaults to ["lib/"].
:excluded_paths
Files under these path prefixes are skipped.
This parameter defaults to [].
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.