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

Credo.Check.Warning.WrongTestFileExtension displayed in non-test module in v1.7.4 #1115

Closed jderr-mx closed 6 months ago

jderr-mx commented 6 months ago

Environment

What were you trying to do?

I am using Neo Vim with coc.nvim and its coc-elixir plugin along with the ElixirLS language server Starting with Credo 1.7.4 I see a warning next to the module name Test files should end with .exs This warning is also generated when using the --read-from-stdin option on the cli This warning disappears when downgrading to Credo 1.7.3

I was able to reproduce it by creating a new mix project named a_project And then opening lib/a_project.ex in my IDE Or running mix credo --read-from-stdin < lib/a_project.ex

Expected outcome

Actual outcome

Screenshot 2024-02-16 at 9 36 46 AM Screenshot 2024-02-16 at 10 14 05 AM
rrrene commented 6 months ago

I can reproduce this. Thx for reporting! :+1:

rrrene commented 6 months ago

@jderr-mx Again, thanks for reporting this. What a stupid regression 😞 It should now be 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! 👍

jderr-mx commented 6 months ago

Hi @rrrene, I verified this fix is working in master

Thank you 🎉

scohen commented 6 months ago

@rrrene this does seem to fix the issue, but the fix seems to have drastically slowed down credo's checks. What used to take 6 or 7 milliseconds now takes more than 50 (at which point lexical stops the plugin from running).

Can I take a stab at improving the performance before you make a release? Releasing main right now will break lexical's credo plugin for whomever uses it (and people won't have credo warnings in their editors any more).

scohen commented 6 months ago

@rrrene you can ignore my comment, the slowdown was only for the first run (likely due to the Regex.compile), subsequent runs are back to the single digit milliseconds, which is plenty fast for lexical.

Can we get a release soon?

RobertoSchneiders commented 6 months ago

Thanks for fixing this, I'm waiting for the release as well.

rrrene commented 6 months ago

@jderr-mx @scohen @RobertoSchneiders This is live in v1.7.5.

scohen commented 6 months ago

Thanks, @rrrene! We love credo.