W0086 - No ?config/2 macro
This diagnostic is disabled by default. Enable it via [linters.no_ct_config_macro] enabled = true
in the project's .elp_lint.toml.
Example
-module(main_SUITE).
my_testcase(Config) ->
PrivDir = ?config(priv_dir, Config).
%% ^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 warning: W0086: The `?config/2` macro is deprecated; use `proplists:get_value/2` instead.
Explanation
The Common Test ?config(Key, Config) macro (from ct.hrl) is defined as
test_server:lookup_config/2, which prints Could not find element ~tp in Config. to stdout when the key is missing. proplists:get_value(Key, Config)
returns undefined silently, so it is preferred.
The two differ on entries that are not {Key, Value} pairs: proplists
treats a bare atom Key as {Key, true}, whereas test_server:lookup_config/2
only ever looks at 2-tuples. A Common Test config is built from 2-tuples, so the
rewrite is equivalent there — which is why the diagnostic only fires in Common
Test suites and test helpers.
Fix
Rewrite the call as proplists:get_value(Key, Config):
my_testcase(Config) ->
PrivDir = proplists:get_value(priv_dir, Config).