rrrene / credo

A static code analysis tool for the Elixir language with a focus on code consistency and teaching.
http://credo-ci.org/
MIT License
4.91k stars 414 forks source link

False positive: spec in quoted #1123

Closed hissssst closed 3 months ago

hissssst commented 5 months ago

Environment

Elixir 1.15.7 (compiled with Erlang/OTP 25)

* Operating system: linux

### What were you trying to do?

I have a function:
```elixir
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 commented 5 months ago

Thx for reporting! :+1:

rrrene commented 4 months ago

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 commented 3 months ago

This is live in v1.7.6 🎉