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

Command line switch `--read-from-stdin` doesn't respect config files #1107

Closed nvieirafelipe closed 8 months ago

nvieirafelipe commented 8 months ago

Environment

1.7.2
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Elixir 1.15.7 (compiled with Erlang/OTP 26)
MacOS Ventura 13.6.1

What were you trying to do?

I'm trying to use credo with https://github.com/mfussenegger/nvim-lint, everything looks fine but when I opened a module that is set in my .credo.exs to be excluded from a specific check I still see credo issues. I think the command line switch --read-from-stdin doesn't respect the configs set in credo config files.

Expected outcome

For example, using the command:

mix credo list --format=oneline --read-from-stdin lib/path_to_file.ex < lib/path_to_file.ex

With the following .credo.exs config:

...
          {Credo.Check.Readability.Specs,
           [
             include_defp: true,
             files: %{
               excluded: [
                 ...
                 "lib/path_to_file.ex",
                 ...
               ]
             }
           ]},
...

I shouldn't see the following output:

[R] → lib/path_to_file.ex:XX:Y Functions should have a @spec type specification.

Actual outcome

Both check and global excluded files configs are ignored.

rrrene commented 8 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 8 months ago

@nvieirafelipe I have an off-topic request that might sound strange: I don't have access to a Mac right now, but got reports mentioning warnings on macOS with Elixir 1.16 (there are no warnings on Ubuntu/Debian/Windows).

Do you have the ability to switch to Elixir 1.16 and do a mix deps.compile && mix credo in a project using Credo? It might be that we missed some compatibility issues with Elixir 1.16, but I thought we caught them all ...

nvieirafelipe commented 8 months ago

Hey René, sure I'll try next week.

nvieirafelipe commented 8 months ago

I didn't saw any warnings compiling credo on elixir 1.16.