Can you pass multiple paths to
credo suggest via the command line? I am attempting to add a precommit hook to lint my changed files with
git --no-pager diff --name-only --cached | grep -E "\.(ex|exs)$" | xargs mix credo
but it appears to only lint the first file in the list (which happens to be
Nope, you can’t.
But you can use
xargs to run
mix credo sequentially for each file.
Still, you really shouldn’t do that. To get the most benefit from credo, you should always let it scan the full project, or it won’t find some of the consistency stuff.
Interesting, my intent with only running it on the staged files is because I know the rest of my code might still be WIP, and might fail the linter check.
I also plan on running credo on my CI, which would run it on every file. With your statement in mind, am I correct in guessing that credo may fail on CI (running on every file) even if it passed in my pre-commit hook (running on a subset of files)?
Consider you had a fully passing credo and all was green.
Then you change a single file which wraps spaces around operators, while all others don’t. You do not touch the other files at all.
Checking only the staged changes will allow you to commit, while your CI will complain, as that one file violates a consitency check now.
That makes sense, thanks for sharing that knowledge!