Open dragonwasrobot opened 5 years ago
It would be nice if all public functions had a @spec type specification so it becomes more obvious from the documentation what types can be given to a function without reading the actual code.
@spec
This would also make it possible for dialyzer to do type inference on the code, e.g. I just came across an issue where a RSAPrivateKey was given to ExPublicKey.encrypt_public but the code ended up failing inside ExPublicKey.RSAPublicKey (https://github.com/ntrepid8/ex_crypto/blob/master/lib/ex_public_key/ex_rsa_public_key.ex#L31) with the error
RSAPrivateKey
ExPublicKey.encrypt_public
ExPublicKey.RSAPublicKey
** (Protocol.UndefinedError) protocol String.Chars not implemented for #ExPublicKey.RSAPrivateKey<fingerprint_sha256=....>. This protocol is implemented for: Ecto.Time, Ecto.DateTime, Ecto.Date, Decimal, Version, Atom, Integer, Version.Requirement, NaiveDateTime, URI, Date, DateTime, BitString, List, Float, Time
because the line
{:error, "invalid ExPublicKey.RSAPublicKey: #{rsa_public_key}"}
did not use #{inspect rsa_public_key}.
#{inspect rsa_public_key}
It would be nice if all public functions had a
@spec
type specification so it becomes more obvious from the documentation what types can be given to a function without reading the actual code.This would also make it possible for dialyzer to do type inference on the code, e.g. I just came across an issue where a
RSAPrivateKey
was given toExPublicKey.encrypt_public
but the code ended up failing insideExPublicKey.RSAPublicKey
(https://github.com/ntrepid8/ex_crypto/blob/master/lib/ex_public_key/ex_rsa_public_key.ex#L31) with the errorbecause the line
did not use
#{inspect rsa_public_key}
.