Browse Source

Merge pull request #63 from seth/sf/fix-warnings

Fix warnings
Seth Falcon 9 years ago
parent
commit
549aad444e
7 changed files with 15 additions and 31 deletions
  1. 2 1
      Makefile
  2. 2 2
      rebar.config
  3. 3 14
      src/pooler.erl
  4. 1 1
      src/pooler.hrl
  5. 3 9
      src/pooler_starter.erl
  6. 1 1
      test/fake_metrics.erl
  7. 3 3
      test/pooled_gs.erl

+ 2 - 1
Makefile

@@ -11,7 +11,8 @@ run: $(REBAR)
 	@$(REBAR) as dev shell --apps pooler --config config/demo.config
 
 test: $(REBAR)
-	$(REBAR) eunit skip_deps=true verbose=3
+	$(REBAR) eunit --cover skip_deps=true verbose=3
+	$(REBAR) cover
 
 doc: $(REBAR)
 	$(REBAR) as dev edoc

+ 2 - 2
rebar.config

@@ -22,8 +22,8 @@
     warn_unused_function,
     warn_deprecated_function,
 
-    strict_validation,
-    warn_missing_spec
+    strict_validation
+    %, warn_missing_spec
 ]}.
 
 {deps, [

+ 3 - 14
src/pooler.erl

@@ -58,11 +58,6 @@
          terminate/2,
          code_change/3]).
 
-%% To help with testing internal functions
--ifdef(TEST).
--compile([export_all]).
--endif.
-
 %% ------------------------------------------------------------------
 %% Application API
 %% ------------------------------------------------------------------
@@ -553,7 +548,8 @@ init_members_sync(N, #pool{name = PoolName} = Pool) ->
             {ok, Pool2}
     end.
 
-collect_init_members(#pool{starting_members = []} = Pool) ->
+collect_init_members(#pool{starting_members = Empty} = Pool)
+  when Empty =:= [] ->
     Pool;
 collect_init_members(#pool{member_start_timeout = StartTimeout} = Pool) ->
     Timeout = time_as_millis(StartTimeout),
@@ -844,11 +840,6 @@ send_metric(#pool{name = PoolName, metrics_mod = MetricsMod,
     MetricName = pool_metric_exometer(PoolName, Label),
     MetricsMod:update_or_create(MetricName, Value, counter, []),
     ok;
-send_metric(#pool{name = PoolName, metrics_mod = MetricsMod,
-                   metrics_api = exometer}, Label, {dec, Value}, counter) ->
-    MetricName = pool_metric_exometer(PoolName, Label),
-    MetricsMod:update_or_create(MetricName, - Value, counter, []),
-    ok;
 % Exometer does not support 'history' type metrics right now.
 send_metric(#pool{name = _PoolName, metrics_mod = _MetricsMod,
                   metrics_api = exometer}, _Label, _Value, history) ->
@@ -932,9 +923,7 @@ terminate_pid(Pid, {Mod, Fun, Args}) when is_list(Args) ->
             terminate_pid(Pid, ?DEFAULT_STOP_MFA);
         _Result ->
             ok
-    end;
-terminate_pid(Pid, _) ->
-    terminate_pid(Pid, ?DEFAULT_STOP_MFA).
+    end.
 
 do_call_free_members(Fun, Pids) ->
     [do_call_free_member(Fun, P) || P <- Pids].

+ 1 - 1
src/pooler.hrl

@@ -99,7 +99,7 @@
           %% A queue of requestors for blocking take member requests
           queued_requestors = queue:new() :: p_requestor_queue(),
           %% The max depth of the queue
-          queue_max = 50
+          queue_max = 50 :: non_neg_integer()
          }).
 
 -define(gv(X, Y), proplists:get_value(X, Y)).

+ 3 - 9
src/pooler_starter.erl

@@ -6,7 +6,6 @@
 -behaviour(gen_server).
 
 -include("pooler.hrl").
--include_lib("eunit/include/eunit.hrl").
 
 %% ------------------------------------------------------------------
 %% API Function Exports
@@ -29,11 +28,6 @@
          terminate/2,
          code_change/3]).
 
-%% To help with testing internal functions
--ifdef(TEST).
--compile([export_all]).
--endif.
-
 %% ------------------------------------------------------------------
 %% API Function Definitions
 %% ------------------------------------------------------------------
@@ -84,9 +78,9 @@ stop_member_async(Pid) ->
 %% ------------------------------------------------------------------
 %% gen_server Function Definitions
 %% ------------------------------------------------------------------
--record(starter, {pool,
-                  parent,
-                  msg}).
+-record(starter, {pool :: #pool{},
+                  parent :: pid() | atom(),
+                  msg :: term()}).
 
 -spec init({#pool{}, pid() | atom()}) -> {'ok', #starter{}, 0}.
 init({Pool, Parent}) ->

+ 1 - 1
test/fake_metrics.erl

@@ -48,7 +48,7 @@ get_metrics() ->
 %% gen_server Function Definitions
 %% ------------------------------------------------------------------
 -record(state, {
-          metrics = []
+          metrics = [] :: list()
          }).
 
 init(_) ->

+ 3 - 3
src/pooled_gs.erl → test/pooled_gs.erl

@@ -75,9 +75,9 @@ stop(S) ->
 %% gen_server Function Definitions
 %% ------------------------------------------------------------------
 -record(state, {
-          type = "",
-          id,
-          ping_count = 0
+          type = "" :: string(),
+          id :: reference(),
+          ping_count = 0 :: non_neg_integer()
          }).
 
 init({Type}) ->