Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/run_test_case.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
run: |
make dialyzer
rm -f rebar.lock
- name: Detect dead code
run: |
make hank
- name: Run tests
run: |
make eunit
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ erlfmt: $(REBAR)
.PHONY: erlfmt-check
erlfmt-check: $(REBAR)
$(REBAR) fmt -c

hank:
$(REBAR) hank
14 changes: 13 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,16 @@
{escript_comment, "%% Hocon 0.1.0"}.
{escript_emu_args, "%%! +sbtu +A1\n"}.
{yrl_opts, [verbose, warnings_as_errors]}.
{project_plugins, [erlfmt]}.

{hank, [
{ignore, [
"include/hoconsc.hrl",
"include/hocon_types.hrl",
"include/hocon.hrl",
%% dynamically generated file
"src/hocon_parser.erl",
"src/hocon_scanner.erl"
]}
]}.

{project_plugins, [erlfmt, {rebar3_hank, "1.4.1"}]}.
6 changes: 3 additions & 3 deletions src/hocon_schema_json.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ gen(Schema, Opts) ->
{RootNs, RootFields, Structs} = hocon_schema:find_structs(Schema, Opts),
Json =
[
gen_struct(RootNs, RootNs, "Root Config Keys", #{fields => RootFields}, Opts)
gen_struct(RootNs, "Root Config Keys", #{fields => RootFields}, Opts)
| lists:map(
fun({Ns, Name, Meta}) ->
case gen_struct(RootNs, Ns, Name, Meta, Opts) of
case gen_struct(Ns, Name, Meta, Opts) of
#{fields := []} = Meta1 ->
error(
{struct_with_no_fields, #{
Expand All @@ -79,7 +79,7 @@ gen(Schema, Opts) ->
],
Json.

gen_struct(_RootNs, Ns, Name, #{fields := Fields} = Meta, Opts) ->
gen_struct(Ns, Name, #{fields := Fields} = Meta, Opts) ->
Paths =
case Meta of
#{paths := Ps} -> lists:sort(maps:keys(Ps));
Expand Down
5 changes: 2 additions & 3 deletions src/hocon_schema_md.erl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fmt_struct(
fmt_paths(Paths),
fmt_envs(Paths, Opts),
"\n\n**Fields**\n\n",
lists:map(fun(F) -> fmt_field(F, Opts) end, Fields)
lists:map(fun(F) -> fmt_field(F) end, Fields)
].

fmt_paths([]) ->
Expand Down Expand Up @@ -95,8 +95,7 @@ fmt_field(
#{
name := Name,
type := Type
} = Field,
_Opts
} = Field
) ->
Default = fmt_default(maps:get(default, Field, undefined)),
Desc = maps:get(desc, Field, ""),
Expand Down
2 changes: 2 additions & 0 deletions test/hocon_schema_aliases_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

-module(hocon_schema_aliases_tests).

-hank([{unnecessary_function_arguments, [{incr, 2}]}]).

-include_lib("eunit/include/eunit.hrl").
-include_lib("typerefl/include/types.hrl").
-include_lib("hocon/include/hoconsc.hrl").
Expand Down
Loading