Deal with dialyzer issues

We end up:
1. making the main interface (`jsx:`) more readable and easier to maintain
(this allows for easier future dropping of the use of `#config{}` for options),
2. fixing some config.-related `-spec(_).`s that weren't using proper elements,
3. having `any()` become a "specific type" - which seems like an improvement,
4. moving stuff like `list()` or `proplists:proplist()` into more appropriate types,
5. making the main config. element (`jsx_config`) "pretty" visible,
6. creating a visible distinction between a module's config. and the generic `jsx_config` elements
This commit is contained in:
Paulo F. Oliveira 2020-09-11 23:09:16 +01:00
parent 1e88fc5455
commit 3a8f364153
10 changed files with 106 additions and 52 deletions

View file

@ -41,21 +41,9 @@
return_maps = false
}).
-type config() :: list().
-export_type([config/0]).
-type config() :: proplists:proplist().
-type json_value() :: list(json_value())
| list({binary() | atom(), json_value()}) | [{},...]
| {with_tail, json_value(), binary()}
| map()
| true
| false
| null
| integer()
| float()
| binary().
-spec to_term(Source::binary(), Config::config()) -> json_value().
-spec to_term(Source::binary(), Config::jsx_config:options()) -> jsx:json_term() | {incomplete, jsx:decoder()}.
to_term(Source, Config) when is_list(Config) ->
(jsx:decoder(?MODULE, [return_maps] ++ Config, jsx_config:extract_config(Config)))(Source).
@ -87,7 +75,7 @@ parse_config([], Config) ->
-type state() :: {list(), #config{}}.
-spec init(Config::proplists:proplist()) -> state().
-spec init(Config::config()) -> state().
init(Config) -> start_term(Config).