I'm running rebar3 on a project with a few 3rd party dependencies, and one of them has an issue with a defined spec. When I moved to rebar3, a new error popped up showing that one of my method calls breaks a contract:
riakc_pb_socket:get(my_app, Bucket::any(), Key::any(), Options::any(),
Timeout::any())
breaks the contract
(pid(), bucket() | bucket_and_type(), key(), get_options(), timeout())
-> {'ok',riakc_obj()} | {'error',term()} | 'unchanged'
In reality, this code works perfectly fine with an atom or a pid. Besides updating the third party lib, is there any way to override that spec without forking the code, or just ignore that specific error?
It is possible to suppress Dialyzer warnings, using -dialyzer(...)
attributes, as documented here.
For your case an appropriate attribute to silence the warning could be something like:
-dialyzer({no_contracts, function_that_calls_riakc_pb_socket_get}).
(Note: I cannot actually test this without the code.)
Keep in mind that, while it can be the case that your "flagged" call works correctly, it may be the intention of the 3rd party library's developer to only support the arguments described by the specified contract (so respecting them could save you from trouble in future versions).