Skip to content

Commit

Permalink
lint toadies
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurii Rashkovskii authored and DeadZen committed Feb 6, 2012
1 parent 0ea64ab commit eaa9c6c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/htoad/src/htoad_toadie_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ load_file(File) ->
"-htoad_absname(\"" ++ File ++ "\").\n"
"-import(htoad_utils, [" ++ Utils ++ "]).\n" ++ S ++ "\n \n",
{Module, Binary} = dynamic_compile:from_string(Source, [export_all,
nowarn_unused_function,nowarn_unused_vars,nowarn_unused_record,
return_errors, debug_info,
{parse_transform, lager_transform},
{i, filename:dirname(File)},
Expand Down
19 changes: 19 additions & 0 deletions apps/htoad/src/htoad_transform.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-module(htoad_transform).
-export([parse_transform/2]).
-include_lib("htoad/include/stdlib.hrl").
-compile({parse_transform, lager_transform}).

-record(state,{
rules = [],
Expand All @@ -12,7 +13,25 @@
absname
}).

-record(context, {module,
function,
arity,
file,
options}).


parse_transform(Forms, Options) ->
#context{ file = File } = parse_trans:initial_context(Forms, Options),
case erl_lint:module(Forms, File, [nowarn_unused_function,nowarn_unused_vars,nowarn_unused_record]) of
{error, Errors, Warnings} ->
(length(Warnings) > 0 andalso
lager:debug("erl_lint warnings in ~s: ~p", [File, Warnings])),
throw({erl_lint, Errors});
{ok, Warnings} when is_list(Warnings), length(Warnings) > 0 ->
lager:debug("erl_lint warnings in ~s: ~p", [File, Warnings]);
_ ->
ok
end,
{Forms1, State} = parse_trans:transform(fun do_transform/4,
#state{ options = Options },
Forms, Options),
Expand Down

0 comments on commit eaa9c6c

Please sign in to comment.