credo
credo copied to clipboard
credo wants a spec for a function that is defoverridable
Environment
- Credo version (
mix credo -v
): 1.6.4 - Erlang/Elixir version (
elixir -v
): Elixir 1.13.4 (compiled with Erlang/OTP 24) - Operating system: macOS 12.13
What were you trying to do?
Please see this example repo where a function is overriden that was defined in a __using__
macro.
The overridable function has a spec but credo wants a new spec.
Defining a spec results in the having the same spec twice in the documentation.
defmodule OverrideSpec do
@moduledoc false
use JokenJwks.DefaultStrategyTemplate
# credo wants this function to have a spec even though it has one already
def init_opts(opts), do: opts
end
Expected outcome
Credo should recognize the already defined spec.
Actual outcome
$ mix credo --strict
Checking 3 source files ...
Code Readability
┃
┃ [R] → Functions should have a @spec type specification.
┃ lib/override_spec.ex:8:7 #(OverrideSpec.init_opts)
Please report incorrect results: https://github.com/rrrene/credo/issues
Analysis took 0.07 seconds (0.05s to load, 0.02s running 65 checks on 3 files)
3 mods/funs, found 1 code readability issue.
Use `mix credo explain` to explain issues, `mix credo --help` for options.
Oops, I forgot to include a link to a project to reproduce this: https://github.com/lukad/credo_override_spec
The check is marked as "experimental" because of limitations like this. If you want to try your hand at a fix, I would gladly review and merge a PR on this :+1:
I apologize for the age/inactivity on this issue.
Please feel free to re-open this issue at your discretion.