Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Cleanup warnings #42

Merged
merged 6 commits into from

3 participants

@seancribbs
Owner
  1. The warn_missing_spec flag is obnoxious, and overkill when we properly dialyze. Removed.
  2. Removed a bunch of miscellaneous warnings about unused variables, functions, and shadowed variables.
  3. Added dialyzer to the Makefile.
  4. Fixed several dialyzer warnings.
seancribbs added some commits
@seancribbs seancribbs Remove warnings about lacking specs. 4254864
@seancribbs seancribbs Address warnings about unused variables and functions. 9ade643
@seancribbs seancribbs Add dialyzer makefile targets. d732191
@seancribbs seancribbs Fix dialyzer warnings.
Fixed:
pokemon_pb.erl:52: The pattern <Default, _> can never match since previous clauses completely covered the type <_,'none'>
pokemon_pb.erl:53: The pattern <Val, _> can never match since previous clauses completely covered the type <_,'none'>
protobuffs.erl:373: Invalid type specification for function protobuffs:encode_field_tag/2. The success typing is (non_neg_integer(),0 | 1 | 2 | 5) -> [integer(),...]
protobuffs.erl:387: Invalid type specification for function protobuffs:encode_varint/1. The success typing is (integer()) -> [integer(),...]
protobuffs.erl:393: Invalid type specification for function protobuffs:encode_varint/2. The success typing is (integer(),[integer()]) -> [integer(),...]

Safe to ignore:
pokemon_pb.erl:46: The variable _ can never match since previous clauses completely covered the type #pikachu{}
7c3612c
@seancribbs seancribbs Remove commented-out code. 078af4d
@seancribbs seancribbs Remove more commented-out code. 4352fef
@seancribbs seancribbs was assigned
@russelldb russelldb was assigned
@russelldb russelldb commented on the diff
src/protobuffs.erl
@@ -26,7 +26,7 @@
%% @doc A protcol buffers encoding and decoding module.
-module(protobuffs).
-%% Pubic
@russelldb Owner

LOL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@russelldb
Owner

Ran dialyzer on this (there are still warnings) and master (there are many more warnings). All the changes make sense and things work as expected. +1 from me

@seancribbs seancribbs merged commit cbe7ee0 into from
@seancribbs seancribbs deleted the branch
@seancribbs seancribbs was assigned
@d11wtq

I just installed riak-erlang-client (latest tag 1.3.1.1) and got a terminal screen sprayed full of warnings from (I assume) this :) Looking at the tags, the last release was 2 months ago. Is there any plan to release an update?

@seancribbs
Owner

@d11wtq Yes, there will be an update soon, probably around the time of the 1.4 release.

@d11wtq

Awesome, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2013
  1. @seancribbs
  2. @seancribbs
  3. @seancribbs
  4. @seancribbs

    Fix dialyzer warnings.

    seancribbs authored
    Fixed:
    pokemon_pb.erl:52: The pattern <Default, _> can never match since previous clauses completely covered the type <_,'none'>
    pokemon_pb.erl:53: The pattern <Val, _> can never match since previous clauses completely covered the type <_,'none'>
    protobuffs.erl:373: Invalid type specification for function protobuffs:encode_field_tag/2. The success typing is (non_neg_integer(),0 | 1 | 2 | 5) -> [integer(),...]
    protobuffs.erl:387: Invalid type specification for function protobuffs:encode_varint/1. The success typing is (integer()) -> [integer(),...]
    protobuffs.erl:393: Invalid type specification for function protobuffs:encode_varint/2. The success typing is (integer(),[integer()]) -> [integer(),...]
    
    Safe to ignore:
    pokemon_pb.erl:46: The variable _ can never match since previous clauses completely covered the type #pikachu{}
Commits on Mar 8, 2013
  1. @seancribbs
Commits on Mar 13, 2013
  1. @seancribbs
This page is out of date. Refresh to see the latest.
View
17 Makefile
@@ -1,5 +1,5 @@
REBAR=`which rebar || printf ./rebar`
-
+REPO=protobuffs
all: get-deps compile
get-deps:
@@ -18,3 +18,18 @@ test: eunit ct
clean:
@$(REBAR) clean
+
+APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \
+ xmerl webtool snmp public_key mnesia eunit syntax_tools compiler
+COMBO_PLT = $(HOME)/.$(REPO)_combo_dialyzer_plt
+
+check_plt: compile
+ dialyzer --check_plt --plt $(COMBO_PLT) --apps $(APPS) \
+ ebin
+
+build_plt: compile
+ dialyzer --build_plt --output_plt $(COMBO_PLT) --apps $(APPS) \
+ ebin
+
+dialyzer: compile
+ dialyzer -Wno_return --plt $(COMBO_PLT) ebin
View
2  rebar.config
@@ -1,4 +1,4 @@
-{erl_opts, [debug_info,warn_missing_spec]}.
+{erl_opts, [debug_info]}.
{deps,[
{meck,"0.*", {git, "git://github.com/eproxus/meck", {branch, "master"}}}
View
1  src/pokemon_pb.erl
@@ -48,7 +48,6 @@ encode_extensions(_) -> [].
iolist(pikachu, Record) ->
[pack(1, required, with_default(Record#pikachu.abc, none), string, [])].
-with_default(Val, none) -> Val;
with_default(Default, Default) -> undefined;
with_default(Val, _) -> Val.
View
8 src/protobuffs.erl
@@ -26,7 +26,7 @@
%% @doc A protcol buffers encoding and decoding module.
-module(protobuffs).
-%% Pubic
@russelldb Owner

LOL!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+%% Public
-export([encode/3, encode_packed/3, decode/2, decode_packed/2]).
%% Used by generated *_pb file. Not intended to used by User
@@ -372,7 +372,7 @@ typecast(Value, _) ->
%% @hidden
-spec encode_field_tag(FieldID :: non_neg_integer(),
FieldType :: encoded_field_type()) ->
- binary().
+ iodata().
encode_field_tag(FieldID, FieldType) when FieldID band 16#3fffffff =:= FieldID ->
encode_varint((FieldID bsl 3) bor FieldType).
@@ -385,13 +385,13 @@ encode_varint_field(FieldID, Integer) ->
%% @hidden
-spec encode_varint(I :: integer()) ->
- binary().
+ iodata().
encode_varint(I) ->
encode_varint(I, []).
%% @hidden
-spec encode_varint(I :: integer(), Acc :: list()) ->
- binary().
+ iodata().
encode_varint(I, Acc) when I =< 16#7f ->
lists:reverse([I | Acc]);
encode_varint(I, Acc) ->
View
62 src/protobuffs_compile.erl
@@ -344,7 +344,7 @@ filter_set_extension([{MsgName,_,Extends}|Tail],Clause,Acc) ->
{match,L2,NewReturn,OldDictStore} = OldSet,
{call,L2,DictStore,[_StoreKey,_StoreVal,StoreVar]} = OldDictStore,
{tuple,L3,[Ok, OldReturnRec]} = OldReturn,
- {record,L3,ReturnRecVar,OldName,Fields} = OldReturnRec,
+ {record,L3,ReturnRecVar,_OldName,Fields} = OldReturnRec,
Folder = fun({Id, Rule, StrType, Name, Opts}, Facc) ->
Type = atomize(StrType),
FClause = {clause,L,[{match,L,{record,L,atomize(MsgName),RecArgFields},RecVar},{atom,L,atomize(Name)},ValueArg],Gs,[
@@ -379,7 +379,7 @@ filter_get_extension_integer([],_,Acc) ->
Acc;
filter_get_extension_integer([{_,_,disallowed}|Tail],IntClause,Acc) ->
filter_get_extension_integer(Tail,IntClause,Acc);
-filter_get_extension_integer([{Msg,_,Extends}|Tail],IntClause,Acc) ->
+filter_get_extension_integer([{Msg,_,_Extends}|Tail],IntClause,Acc) ->
{clause,L,[{record,L,Pikachu,Fields},IntArg],Gs,Body} = IntClause,
NewRecName = replace_atom(Pikachu, pikachu, atomize(Msg)),
NewRecArg = {record,L,NewRecName,Fields},
@@ -391,13 +391,13 @@ filter_get_extension_integer([{Msg,_,Extends}|Tail],IntClause,Acc) ->
filter_has_extension([], _, Acc) ->
% non-reverseal is intentional.
Acc;
-filter_has_extension([{Msg,_,disallowed}|Tail], Clause, Acc) ->
+filter_has_extension([{_Msg,_,disallowed}|Tail], Clause, Acc) ->
filter_has_extension(Tail, Clause, Acc);
filter_has_extension([{MsgName,_,Extends}|Tail], Clause, Acc) ->
{clause,L,[OldRecArg,_],G,[Body]} = Clause,
{call, L1, {remote,L1,Dict,IsKey},[_Key,DictArg]} = Body,
RecArg = replace_atom(OldRecArg,pikachu,atomize(MsgName)),
- Folder = fun({ID, Rules, Type, Name, Other}, FoldAcc) ->
+ Folder = fun({ID, _Rules, _Type, Name, _Other}, FoldAcc) ->
AtomClause = {clause,L,[RecArg,{atom,L,atomize(Name)}],G,[
{call,L,{remote,L,Dict,IsKey},[{atom,L,atomize(Name)},DictArg]}
]},
@@ -414,7 +414,7 @@ filter_has_extension([{MsgName,_,Extends}|Tail], Clause, Acc) ->
filter_extension_size([], _RecClause, Acc) ->
% the non-reversal is intentional.
Acc;
-filter_extension_size([{MsgName,_,disallowed}|Tail],Clause,Acc) ->
+filter_extension_size([{_MsgName,_,disallowed}|Tail],Clause,Acc) ->
filter_extension_size(Tail,Clause,Acc);
filter_extension_size([{MsgName,_,_}|Tail],Clause,Acc) ->
{clause,L,[OldArg],G,Body} = Clause,
@@ -423,7 +423,7 @@ filter_extension_size([{MsgName,_,_}|Tail],Clause,Acc) ->
filter_extension_size(Tail,Clause,NewAcc).
%% @hidden
-filter_encode_clause({MsgName, _Fields,_Extends}, {clause,L,_Args,Guards,Content}) ->
+filter_encode_clause({MsgName, _Fields,_Extends}, {clause,L,_Args,Guards,_Content}) ->
ToIolist = {cons, L,
{call,L, {atom,L,iolist}, [{atom,L,atomize(MsgName)},{var,L,'Record'}]},
{call,L, {atom,L,encode_extensions}, [{var,L,'Record'}]}
@@ -433,7 +433,7 @@ filter_encode_clause({MsgName, _Fields,_Extends}, {clause,L,_Args,Guards,Content
expand_iolist_function(Msgs, Line, Clause) ->
{function,Line,iolist,2,[filter_iolist_clause(Msg, Clause) || Msg <- Msgs]}.
-filter_iolist_clause({MsgName, [], _Extends0}, {clause,L,Args,Guards,_Content}) ->
+filter_iolist_clause({MsgName, [], _Extends0}, {clause,L,_Args,Guards,_Content}) ->
{clause,L,[{atom,L,atomize(MsgName)},{var,L,'_Record'}],Guards,[{nil,L}]};
filter_iolist_clause({MsgName, Fields0, _Extends0}, {clause,L,_Args,Guards,_Content}) ->
Fields = [
@@ -507,8 +507,8 @@ filter_decode_extensions_clause(Msgs,[{MsgName,_,Extends}|Tail],Clause,Acc) ->
decode_opts(Msgs, Tag, SType), Def} ||
{FNum,Tag,SType,SName,Def} <- Extends]),
Cons = lists:foldl(
- fun({FNum, FName, Type, Opts, _Def}, Acc) ->
- {cons,L,{tuple,L,[{integer,L,FNum},{atom,L,FName},{atom,L,Type},erl_parse:abstract(Opts)]},Acc}
+ fun({FNum, FName, Type, Opts, _Def}, AccF) ->
+ {cons,L,{tuple,L,[{integer,L,FNum},{atom,L,FName},{atom,L,Type},erl_parse:abstract(Opts)]},AccF}
end, {nil,L}, Types),
A = {match,L,{var,L,'Types'},Cons},
{clause,L,[Arg],Guards,[_,B,C]} = Clause,
@@ -535,7 +535,7 @@ expand_to_record_function(Msgs, Line, Clause) ->
{function,Line,to_record,2,[filter_to_record_clause(Msg, Clause) || Msg <- Msgs]}.
%% @hidden
-filter_to_record_clause({MsgName, _, Extends}, {clause,L,[_Param1,Param2],Guards,[Fold,DecodeExtends]}) ->
+filter_to_record_clause({MsgName, _, Extends}, {clause,L,[_Param1,Param2],Guards,[Fold,_DecodeExtends]}) ->
Fold1 = replace_atom(Fold, pikachu, atomize(MsgName)),
ReturnLine = case Extends of
disallowed ->
@@ -641,11 +641,9 @@ collect_full_messages([{extend, Name, ExtendedFields} | Tail], Collected) ->
SeekNames0 = resolve_list_name(SeekName1, Collected#collected.package),
SeekNames = [list_to_tuple(SN) || SN <- SeekNames0],
- #collected{msg = CollectedMsg, extensions = Extended} = Collected,
+ #collected{msg = CollectedMsg} = Collected,
BestMatch = element(1, find_message_by_path(SeekNames, CollectedMsg)),
- %{ListNameT,FieldsOut,ExtendFields} = find_extended_msg(ListName, CollectedMsg),
- %{ListNameT2,Extensions} = find_defined_extensions(ListName, Extended),
{ListName,FieldsOut,ExtendFields} = lists:keyfind(BestMatch,1,CollectedMsg),
{ListName,Extensions} = lists:keyfind(BestMatch,1,Collected#collected.extensions),
@@ -704,36 +702,6 @@ find_message_by_path(TypeName, [Msg | Tail]) ->
end.
%% @hidden
-find_extended_msg(_TypeName, []) ->
- false;
-find_extended_msg(TypeName, Msgs) when is_list(hd(TypeName)) ->
- TypeName0 = [list_to_tuple(TN) || TN <- TypeName],
- find_extended_msg(TypeName0, Msgs);
-find_extended_msg(TypeName, [Msg | Tail]) ->
- Names = element(1, Msg),
- case [N || N <- Names, lists:member(N, TypeName)] of
- [] ->
- find_extended_msg(TypeName, Tail);
- _ ->
- Msg
- end.
-
-%% @hidden
-find_defined_extensions(TypeName, []) ->
- false;
-find_defined_extensions(TypeName, Extends) when is_list(hd(TypeName)) ->
- TypeName0 = [list_to_tuple(TN) || TN <- TypeName],
- find_defined_extensions(TypeName0, Extends);
-find_defined_extensions(TypeName, [Ext | Tail]) ->
- Names = element(1, Ext),
- case [N || N <- Names] of
- [] ->
- find_defined_extensions(TypeName, Tail);
- _ ->
- Ext
- end.
-
-%% @hidden
resolve_list_name(Name, _Package) when is_tuple(hd(Name)) ->
[tuple_to_list(N) || N <- Name];
resolve_list_name(Name, undefined) when is_integer(hd(Name)) ->
@@ -895,14 +863,6 @@ all_possible_type_paths(_Type, [], Acc) ->
lists:reverse(lists:flatten(Acc));
all_possible_type_paths(Type, [TypePath | Tail], Acc) ->
TypePath0 = tuple_to_list(TypePath),
-% Type0 = if
-% is_list(hd(Type)) -> Type;
-% true -> [Type]
-% end,
-% FoldFun = fun(TypeSuffix, AccIn) ->
-% [[Type0 ++ TypeSuffix] | AccIn]
-% end,
-% lists:foldl(FoldFun, Type0, TypePath).
Head = lists:foldl(fun (TypeSuffix, AccIn) ->
[list_to_tuple([Type | TypeSuffix]) | AccIn]
end,
View
20 test/erlang_protobuffs_SUITE.erl
@@ -166,7 +166,7 @@ test_proto_files(Config) ->
test_server:format("Test ~p: ok~n~n~n",
[Message]),
Acc andalso true;
- F ->
+ _ ->
test_server:format("Test ~p: Failed with ~p~n~n~n",
[Message, Result]),
false
@@ -180,15 +180,15 @@ test_proto_files(Config) ->
test_extendable_messages(Config) ->
DataDir = (?config(data_dir, Config)),
NumTests = (?config(num_tests, Config)),
- ProtoFiles = [begin
- Filename = filename:join([DataDir, "proto", X]),
- Path = filename:absname(Filename),
- Options = [{imports_dir,
- [filename:join([DataDir, "proto"]),
- filename:join([DataDir, "proto", "import"])]}],
- protobuffs_compile:scan_file(Path, Options)
- end
- || X <- ["extend.proto", "extensions.proto"]],
+ [begin
+ Filename = filename:join([DataDir, "proto", X]),
+ Path = filename:absname(Filename),
+ Options = [{imports_dir,
+ [filename:join([DataDir, "proto"]),
+ filename:join([DataDir, "proto", "import"])]}],
+ protobuffs_compile:scan_file(Path, Options)
+ end
+ || X <- ["extend.proto", "extensions.proto"]],
Tests = [proper_protobuffs_extend_degraded,
proper_protobuffs_extend_assign,
proper_protobuffs_extend_get,
View
5 test/protobuffs_proper.erl
@@ -442,7 +442,7 @@ proper_protobuffs_assign_encode() ->
Expected = {extendable,
dict:from_list([{126,
{optional, Extend, sint32, []}}])},
- {ok, Middle} = extend_pb:set_extension(Input, bar,
+ {ok, _Middle} = extend_pb:set_extension(Input, bar,
Extend),
Output =
extend_pb:decode_extendable(extend_pb:encode_extendable(Expected)),
@@ -453,9 +453,6 @@ proper_protobuffs_extend_get() ->
?FORALL(Extend, (sint32()),
begin
Input = {extendable, dict:new()},
- Encodable = {extendable,
- dict:from_list([{126,
- {optional, Extend, sint32, []}}])},
{ok, Middle} = extend_pb:set_extension(Input, bar,
Extend),
Decoded =
View
2  test/protobuffs_tests.erl
@@ -478,7 +478,7 @@ encode_packed_enum_test_() ->
(?ENCODE_PACKED(0, [0, 0], enum)))].
decode_packed_enum_test_() ->
- [?_assertMatch({{Id, [0, 0]}, <<>>},
+ [?_assertMatch({{_Id, [0, 0]}, <<>>},
(?DECODE_PACKED(<<2, 2, 0, 0>>, enum)))].
prop_packed_uint32() ->
Something went wrong with that request. Please try again.