Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dialyzer errors #42

Open
drozzy opened this issue Jul 27, 2021 · 1 comment
Open

Fix dialyzer errors #42

drozzy opened this issue Jul 27, 2021 · 1 comment

Comments

@drozzy
Copy link
Member

drozzy commented Jul 27, 2021

Currently (July 27, 2021) there are these dialyzer errors. I'm sure some are not important, but I'm placing them here just as a reference.

src/chumak_command.erl
Line 295 Column 1: Function decode_hello_message/2 has no local return
Line 320 Column 1: Function decode_welcome_message/2 has no local return
Line 353 Column 1: Function decode_initiate_message/2 has no local return
Line 408 Column 1: Function decode_curve_ready_message/2 has no local return
Line 430 Column 1: Function decode_curve_message/2 has no local return

src/chumak_curve.erl
Line 141 Column 1: Function receive_command/1 will never be called
Line 191 Column 1: Function send_hello_step/2 will never be called
Line 220 Column 1: Function send_welcome_step/2 will never be called
Line 230 Column 1: Function send_initiate_step/3 will never be called
Line 240 Column 1: Function send_ready_step/3 will never be called
Line 251 Column 1: Function validate_client_curve_data/1 has no local return
Line 261 Column 1: Function validate_server_curve_data/1 has no local return

src/chumak_curve_if.erl
Line 40 Column 1: Function randombytes/1 has no local return
Line 44 Column 9: The variable _ can never match since previous clauses completely covered the type 'none'
Line 50 Column 1: Function box_keypair/0 has no local return
Line 54 Column 9: The pattern 'nacl' can never match the type 'none'
Line 57 Column 9: The variable _ can never match since previous clauses completely covered the type 'none'
Line 71 Column 1: Function box/4 has no local return
Line 75 Column 9: The pattern 'nacl' can never match the type 'none'
Line 78 Column 9: The variable _ can never match since previous clauses completely covered the type 'none'
Line 92 Column 1: Function box_open/4 has no local return
Line 96 Column 9: The pattern 'nacl' can never match the type 'none'
Line 99 Column 9: The variable _ can never match since previous clauses completely covered the type 'none'

src/chumak_dealer.erl
Line 100 Column 13: The pattern {'error', Info} can never match the type 'empty' | {'out',[any()]}

src/chumak_peer.erl
Line 343 Column 9: The pattern {'ok', NewState} can never match the type {'error',{'error',{'invalid_command_before_ready',_}} | {'shutdown','invalid_resource' | {'server_error',_}},#state{step::'ready' | 'waiting_peer' | 'waiting_ready',host::'nil' | string(),port::'nil' | number(),conn_side::'client' | 'server',resource::string(),type::'dealer' | 'pair' | 'pub' | 'pull' | 'push' | 'rep' | 'req' | 'router' | 'sub' | 'xpub' | 'xsub',identity::string(),peer_identity::string(),peer_version::{integer(),integer()},socket::'nil' | port() | {'$inet',atom(),_},decoder::{'decoder','command_ready' | 'initial' | 'message_ready' | 'ready' | 'require_size' | 'waiting_as_server' | 'waiting_filler' | 'waiting_mechanism' | 'waiting_minor_version',integer(),'nil' | binary(),'command_ready' | 'initial' | 'message_ready' | 'nil' | 'ready' | 'require_size' | 'waiting_as_server' | 'waiting_filler' | 'waiting_mechanism' | 'waiting_minor_version','nil' | {_,_},'nil' | {_,_},map(),'curve' | 'nil' | 'null',boolean()},parent_pid::pid(),incoming_queue::'nil' | queue:queue(_),msg_buf::[any()],pub_compatible_layer::boolean(),multi_socket_type::boolean(),as_server::boolean(),mechanism::'curve' | 'null',security_data::#{'client_nonce'=>integer(), 'client_public_transient_key'=>binary(), 'client_secret_transient_key'=>binary(), 'cookie_public_key'=>binary(), 'cookie_secret_key'=>binary(), 'curve_publickey'=>binary(), 'curve_secretkey'=>binary(), 'curve_serverkey'=>binary(), 'mechanism'=>'curve', 'role'=>'client' | 'server', 'server_nonce'=>integer(), 'server_public_transient_key'=>binary(), 'server_secret_transient_key'=>binary()}}}
Line 352 Column 2: Invalid type specification for function chumak_peer:handshake/1. The success typing is (#state{step::'ready' | 'waiting_peer' | 'waiting_ready',host::'nil' | string(),port::'nil' | number(),conn_side::'client' | 'server',resource::string(),type::'dealer' | 'pair' | 'pub' | 'pull' | 'push' | 'rep' | 'req' | 'router' | 'sub' | 'xpub' | 'xsub',identity::string(),peer_identity::string(),peer_version::{integer(),integer()},socket::port() | {'$inet',atom(),_},decoder::{'decoder','ready',integer(),binary(),'command_ready' | 'initial' | 'message_ready' | 'nil' | 'ready' | 'require_size' | 'waiting_as_server' | 'waiting_filler' | 'waiting_mechanism' | 'waiting_minor_version',{'some',integer()},{'some',integer()},#{'client_nonce'=>integer(), 'client_public_transient_key'=>binary(), 'client_secret_transient_key'=>binary(), 'cookie_public_key'=>binary(), 'cookie_secret_key'=>binary(), 'curve_publickey'=>binary(), 'curve_secretkey'=>binary(), 'curve_serverkey'=>binary(), 'mechanism'=>'curve', 'role'=>'client' | 'server', 'server_nonce'=>integer(), 'server_public_transient_key'=>binary(), 'server_secret_transient_key'=>binary()},'curve' | 'nil' | 'null',boolean()},parent_pid::pid(),incoming_queue::'nil' | queue:queue(_),msg_buf::[any()],pub_compatible_layer::boolean(),multi_socket_type::boolean(),as_server::boolean(),mechanism::'curve' | 'null',security_data::#{'client_nonce'=>integer(), 'client_public_transient_key'=>binary(), 'client_secret_transient_key'=>binary(), 'cookie_public_key'=>binary(), 'cookie_secret_key'=>binary(), 'curve_publickey'=>binary(), 'curve_secretkey'=>binary(), 'curve_serverkey'=>binary(), 'mechanism'=>'curve', 'role'=>'client' | 'server', 'server_nonce'=>integer(), 'server_public_transient_key'=>binary(), 'server_secret_transient_key'=>binary()}}) -> {'error',{'error',{'invalid_command_before_ready',_}} | {'shutdown','invalid_resource' | {'server_error',_}},#state{step::'ready' | 'waiting_peer' | 'waiting_ready',host::'nil' | string(),port::'nil' | number(),conn_side::'client' | 'server',resource::string(),type::'dealer' | 'pair' | 'pub' | 'pull' | 'push' | 'rep' | 'req' | 'router' | 'sub' | 'xpub' | 'xsub',identity::string(),peer_identity::string(),peer_version::{integer(),integer()},socket::'nil' | port() | {'$inet',atom(),_},decoder::{'decoder','command_ready' | 'initial' | 'message_ready' | 'ready' | 'require_size' | 'waiting_as_server' | 'waiting_filler' | 'waiting_mechanism' | 'waiting_minor_version',integer(),'nil' | binary(),'command_ready' | 'initial' | 'message_ready' | 'nil' | 'ready' | 'require_size' | 'waiting_as_server' | 'waiting_filler' | 'waiting_mechanism' | 'waiting_minor_version','nil' | {_,_},'nil' | {_,_},map(),'curve' | 'nil' | 'null',boolean()},parent_pid::pid(),incoming_queue::'nil' | queue:queue(_),msg_buf::[any()],pub_compatible_layer::boolean(),multi_socket_type::boolean(),as_server::boolean(),mechanism::'curve' | 'null',security_data::#{'client_nonce'=>integer(), 'client_public_transient_key'=>binary(), 'client_secret_transient_key'=>binary(), 'cookie_public_key'=>binary(), 'cookie_secret_key'=>binary(), 'curve_publickey'=>binary(), 'curve_secretkey'=>binary(), 'curve_serverkey'=>binary(), 'mechanism'=>'curve', 'role'=>'client' | 'server', 'server_nonce'=>integer(), 'server_public_transient_key'=>binary(), 'server_secret_transient_key'=>binary()}}}
Line 392 Column 9: The pattern {'ok', ReadyState} can never match the type {'error',{'error',{'invalid_command_before_ready',_}} | {'shutdown','invalid_resource' | {'server_error',_}},#state{step::'ready' | 'waiting_peer' | 'waiting_ready',host::'nil' | string(),port::'nil' | number(),conn_side::'client' | 'server',resource::string(),type::'dealer' | 'pair' | 'pub' | 'pull' | 'push' | 'rep' | 'req' | 'router' | 'sub' | 'xpub' | 'xsub',identity::string(),peer_identity::string(),peer_version::{integer(),integer()},socket::'nil' | port() | {'$inet',atom(),_},decoder::{'decoder','command_ready' | 'initial' | 'message_ready' | 'ready' | 'require_size' | 'waiting_as_server' | 'waiting_filler' | 'waiting_mechanism' | 'waiting_minor_version',integer(),'nil' | binary(),'command_ready' | 'initial' | 'message_ready' | 'nil' | 'ready' | 'require_size' | 'waiting_as_server' | 'waiting_filler' | 'waiting_mechanism' | 'waiting_minor_version','nil' | {'some',integer()},'nil' | {'some',integer()},#{'client_nonce'=>integer(), 'client_public_transient_key'=>binary(), 'client_secret_transient_key'=>binary(), 'cookie_public_key'=>binary(), 'cookie_secret_key'=>binary(), 'curve_publickey'=>binary(), 'curve_secretkey'=>binary(), 'curve_serverkey'=>binary(), 'mechanism'=>'curve', 'role'=>'client' | 'server', 'server_nonce'=>integer(), 'server_public_transient_key'=>binary(), 'server_secret_transient_key'=>binary()},'curve' | 'nil' | 'null',boolean()},parent_pid::pid(),incoming_queue::'nil' | queue:queue(_),msg_buf::[any()],pub_compatible_layer::boolean(),multi_socket_type::boolean(),as_server::boolean(),mechanism::'curve' | 'null',security_data::#{'client_nonce'=>integer(), 'client_public_transient_key'=>binary(), 'client_secret_transient_key'=>binary(), 'cookie_public_key'=>binary(), 'cookie_secret_key'=>binary(), 'curve_publickey'=>binary(), 'curve_secretkey'=>binary(), 'curve_serverkey'=>binary(), 'mechanism'=>'curve', 'role'=>'client' | 'server', 'server_nonce'=>integer(), 'server_public_transient_key'=>binary(), 'server_secret_transient_key'=>binary()}}}
Line 445 Column 1: Function handle_ready_response2/2 has no local return
Line 460 Column 1: Function validate_peer_socket_type/2 has no local return
Line 466 Column 10: The call PatternModule:'valid_peer_type'(PeerSocketType::atom()) requires that PatternModule is of type atom() not {'error','invalid_socket_type'}
Line 587 Column 1: Function send_invalid_socket_type_error/3 will never be called

src/chumak_protocol.erl
Line 158 Column 1: Function build_hello_frame/1 has no local return
Line 224 Column 1: Function build_welcome_frame/1 has no local return
Line 319 Column 1: Function build_initiate_frame/2 has no local return
Line 395 Column 1: Function build_ready_frame/2 has no local return
Line 673 Column 2: Invalid type specification for function chumak_protocol:encode_more_message/3. The success typing is (binary(),_,_) -> {nonempty_binary(),_}
Line 685 Column 2: Invalid type specification for function chumak_protocol:encode_last_message/3. The success typing is (binary(),_,_) -> {nonempty_binary(),_}

src/chumak_pub.erl
Line 128 Column 9: The pattern {'error', Info} can never match the type 'empty' | {'out',[any()]}

src/chumak_pull.erl
Line 120 Column 9: The pattern {'error', Info} can never match the type 'empty' | {'out',[any()]}

src/chumak_rep.erl
Line 141 Column 9: The pattern {'error', Info} can never match the type 'empty' | {'out',[any()]}

src/chumak_router.erl
Line 108 Column 9: The pattern {'error', Info} can never match the type 'empty' | {'out',[any()]}
Line 125 Column 1: Function terminate_lbs/1 will never be called
Line 131 Column 1: Function terminate_lb/1 will never be called

src/chumak_socket.erl
Line 43 Column 9: The variable ModuleName can never match since previous clauses completely covered the type {'error','invalid_socket_type'}

src/chumak_sub.erl
Line 130 Column 9: The pattern {'error', Info} can never match the type 'empty' | {'out',[any()]}
===> Warnings written to _build/default/24.0.4.dialyzer_warnings
===> Warnings occurred running dialyzer: 45
@filmor
Copy link
Contributor

filmor commented Oct 1, 2021

A few observations:

  • The has no local return errors come from building without having a NaCl library set.
  • There are quite a few "generic" map() specs instead of specific ones

The PR fixes all issues outside of chumak_curve, I'll have another look at that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants