Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix dialyzer warnings and make all the records typed #188

Merged
merged 1 commit into from

4 participants

@Vagabond
Collaborator

No description provided.

@reiddraper

I get these errors:

lager.erl:191: Function stop_trace/1 has no local return
lager.erl:211: Function clear_all_traces/0 has no local return
lager.erl:213: The call lager_util:trace_filter('none') will never return since it differs in the 1st argument from the success typing arguments: (nonempty_maybe_improper_list())
lager_app.erl:35: Function start/2 has no local return
lager_app.erl:116: The call lager_util:trace_filter('none') will never return since it differs in the 1st argument from the success typing arguments: (nonempty_maybe_improper_list())
Unknown functions:
  lager_default_tracer:info/1

Were those expected?

@Vagabond Vagabond merged commit 6a7a456 into from
@seancribbs seancribbs deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 24, 2014
  1. @Vagabond
This page is out of date. Refresh to see the latest.
View
2  rebar.config
@@ -1,4 +1,4 @@
-{erl_opts, [debug_info]}.
+{erl_opts, [debug_info, warn_untyped_record]}.
{erl_first_files, ["src/lager_util.erl"]}.
{deps, [
{goldrush, ".*",
View
6 src/lager.erl
@@ -191,7 +191,7 @@ trace(Backend, Filter, Level) ->
stop_trace({_Filter, _Level, Target} = Trace) ->
{Level, Traces} = lager_config:get(loglevel),
NewTraces = lists:delete(Trace, Traces),
- lager_util:trace_filter([ element(1, T) || T <- NewTraces ]),
+ _ = lager_util:trace_filter([ element(1, T) || T <- NewTraces ]),
%MinLevel = minimum_loglevel(get_loglevels() ++ get_trace_levels(NewTraces)),
lager_config:set(loglevel, {Level, NewTraces}),
case get_loglevel(Target) of
@@ -210,7 +210,7 @@ stop_trace({_Filter, _Level, Target} = Trace) ->
clear_all_traces() ->
{Level, _Traces} = lager_config:get(loglevel),
- lager_util:trace_filter(none),
+ _ = lager_util:trace_filter(none),
lager_config:set(loglevel, {Level, []}),
lists:foreach(fun(Handler) ->
case get_loglevel(Handler) of
@@ -319,7 +319,7 @@ add_trace_to_loglevel_config(Trace) ->
case lists:member(Trace, Traces) of
false ->
NewTraces = [Trace|Traces],
- lager_util:trace_filter([ element(1, T) || T <- NewTraces]),
+ _ = lager_util:trace_filter([ element(1, T) || T <- NewTraces]),
lager_config:set(loglevel, {MinLevel, [Trace|Traces]});
_ ->
ok
View
2  src/lager_app.erl
@@ -113,7 +113,7 @@ start(_StartType, _StartArgs) ->
end
end,
- lager_util:trace_filter(none),
+ _ = lager_util:trace_filter(none),
{ok, Pid, SavedHandlers}.
View
6 src/lager_backend_throttle.erl
@@ -30,9 +30,9 @@
code_change/3]).
-record(state, {
- hwm,
- window_min,
- async = true
+ hwm :: non_neg_integer(),
+ window_min :: non_neg_integer(),
+ async = true :: boolean()
}).
init([Hwm, Window]) ->
View
5 src/lager_console_backend.erl
@@ -24,7 +24,10 @@
-export([init/1, handle_call/2, handle_event/2, handle_info/2, terminate/2,
code_change/3]).
--record(state, {level, formatter,format_config,colors=[]}).
+-record(state, {level :: {'mask', integer()},
+ formatter :: atom(),
+ format_config :: any(),
+ colors=[] :: list()}).
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
View
20 src/lager_crash_log.erl
@@ -45,14 +45,14 @@
-export([start_link/5, start/5]).
-record(state, {
- name,
- fd,
- inode,
- fmtmaxbytes,
- size,
- date,
- count,
- flap=false
+ name :: string(),
+ fd :: pid(),
+ inode :: integer(),
+ fmtmaxbytes :: integer(),
+ size :: integer(),
+ date :: undefined | string(),
+ count :: integer(),
+ flap=false :: boolean()
}).
%% @private
@@ -95,7 +95,7 @@ handle_cast(_Request, State) ->
%% @private
handle_info(rotate, #state{name=Name, count=Count, date=Date} = State) ->
- lager_util:rotate_logfile(Name, Count),
+ _ = lager_util:rotate_logfile(Name, Count),
schedule_rotation(Date),
{noreply, State};
handle_info(_Info, State) ->
@@ -199,7 +199,7 @@ do_log({log, Event}, #state{name=Name, fd=FD, inode=Inode, flap=Flap,
true ->
case lager_util:ensure_logfile(Name, FD, Inode, false) of
{ok, {_, _, Size}} when RotSize /= 0, Size > RotSize ->
- lager_util:rotate_logfile(Name, Count),
+ _ = lager_util:rotate_logfile(Name, Count),
handle_cast({log, Event}, State);
{ok, {NewFD, NewInode, _Size}} ->
{Date, TS} = lager_util:format_time(
View
20 src/lager_file_backend.erl
@@ -62,15 +62,15 @@
inode :: integer(),
flap=false :: boolean(),
size = 0 :: integer(),
- date,
- count = 10,
- formatter,
- formatter_config,
- sync_on,
- check_interval = ?DEFAULT_CHECK_INTERVAL,
- sync_interval = ?DEFAULT_SYNC_INTERVAL,
- sync_size = ?DEFAULT_SYNC_SIZE,
- last_check = os:timestamp()
+ date :: undefined | string(),
+ count = 10 :: integer(),
+ formatter :: atom(),
+ formatter_config :: any(),
+ sync_on :: {'mask', integer()},
+ check_interval = ?DEFAULT_CHECK_INTERVAL :: non_neg_integer(),
+ sync_interval = ?DEFAULT_SYNC_INTERVAL :: non_neg_integer(),
+ sync_size = ?DEFAULT_SYNC_SIZE :: non_neg_integer(),
+ last_check = os:timestamp() :: erlang:timestamp()
}).
-type option() :: {file, string()} | {level, lager:log_level()} |
@@ -147,7 +147,7 @@ handle_event(_Event, State) ->
%% @private
handle_info({rotate, File}, #state{name=File,count=Count,date=Date} = State) ->
- lager_util:rotate_logfile(File, Count),
+ _ = lager_util:rotate_logfile(File, Count),
schedule_rotation(File, Date),
{ok, State};
handle_info(_Info, State) ->
View
2  src/lager_format.erl
@@ -23,7 +23,7 @@
-export([format/3, format/4]).
-record(options, {
- chomp = false
+ chomp = false :: boolean()
}).
format(FmtStr, Args, MaxLen) ->
View
6 src/lager_handler_watcher.erl
@@ -36,9 +36,9 @@
-export([start_link/3, start/3]).
-record(state, {
- module,
- config,
- event
+ module :: atom(),
+ config :: any(),
+ event :: pid() | atom()
}).
start_link(Event, Module, Config) ->
View
9 src/lager_util.erl
@@ -353,17 +353,16 @@ calculate_next_rotation([{date, Date}|T], {{Year, Month, Day}, _} = Now) ->
NewNow = calendar:gregorian_seconds_to_datetime(Seconds),
calculate_next_rotation(T, NewNow).
-
+-spec trace_filter(Query :: 'none' | [tuple()]) -> {ok, any()}.
trace_filter(Query) ->
trace_filter(?DEFAULT_TRACER, Query).
%% TODO: Support multiple trace modules
+%-spec trace_filter(Module :: atom(), Query :: 'none' | [tuple()]) -> {ok, any()}.
trace_filter(Module, Query) when Query == none; Query == [] ->
- trace_filter(Module, glc:null(false));
+ {ok, _} = glc:compile(Module, glc:null(false));
trace_filter(Module, Query) when is_list(Query) ->
- trace_filter(Module, glc_lib:reduce(trace_any(Query)));
-trace_filter(Module, Query) ->
- {ok, _} = glc:compile(Module, Query).
+ {ok, _} = glc:compile(Module, glc_lib:reduce(trace_any(Query))).
validate_trace({Filter, Level, {Destination, ID}}) when is_tuple(Filter); is_list(Filter), is_atom(Level), is_atom(Destination) ->
case validate_trace({Filter, Level, Destination}) of
View
8 tools.mk
@@ -17,16 +17,22 @@ else
endif
${LOCAL_PLT}: compile
+ifneq (,$(wildcard deps/*))
ifneq (,$(wildcard $(LOCAL_PLT)))
dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \
dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1
else
dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1
endif
+endif
dialyzer: ${PLT} ${LOCAL_PLT}
@echo "==> $(shell basename $(shell pwd)) (dialyzer)"
- dialyzer $(DIALYZER_FLAGS) --plts $(PLT) $(LOCAL_PLT) -c ebin
+ @if [ -f $(LOCAL_PLT) ]; then \
+ dialyzer $(DIALYZER_FLAGS) --plts $(PLT) $(LOCAL_PLT) -c ebin; \
+ else \
+ dialyzer $(DIALYZER_FLAGS) --plts $(PLT) -c ebin; \
+ fi
cleanplt:
@echo
Something went wrong with that request. Please try again.