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

False positive: spec in quoted #1123

Closed
hissssst opened this issue Mar 30, 2024 · 3 comments
Closed

False positive: spec in quoted #1123

hissssst opened this issue Mar 30, 2024 · 3 comments

Comments

@hissssst
Copy link

Environment

  • Credo version (mix credo -v): 1.7.5-ref.master.c5b4d38+uncommittedchanges
  • Erlang/Elixir version (elixir -v):
Erlang/OTP 25 [erts-13.2.2.6] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Elixir 1.15.7 (compiled with Erlang/OTP 25)
  • Operating system: linux

What were you trying to do?

I have a function:

1  @spec to_def(t(), atom()) :: Macro.t()
2  def to_def(%__MODULE__{vars: vars, code: code}, name) do
3    quote generated: true do
4      def unquote(name)(unquote_splicing(vars)) do
5        unquote(code)
6      end
7    end
8  end

Expected outcome

It does not complain that line 4 has no spec, since it is a generated function

Actual outcome

It complains that the def on line 4 has no spec

  Code Readability
┃
┃ [R] → Functions should have a @spec type specification.
┃       lib/file.ex:4:column #(Module.to_def)

Real world example

Run mix credo here: https://github.com/hissssst/pathex

@rrrene
Copy link
Owner

rrrene commented Mar 31, 2024

Thx for reporting! 👍

rrrene added a commit that referenced this issue Apr 11, 2024
@rrrene
Copy link
Owner

rrrene commented Apr 11, 2024

Thanks for reporting this 😀 It is now fixed on master.

You can try this by setting the Credo dep to

{:credo, github: "rrrene/credo"}

Please report back if your issue is solved! 👍

@rrrene
Copy link
Owner

rrrene commented May 9, 2024

This is live in v1.7.6 🎉

@rrrene rrrene closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants