-
Notifications
You must be signed in to change notification settings - Fork 0
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
Proposal: Allow passing a list of files to mix credo
#4
Comments
+1 |
Is someone working on this to make this happen? |
Credo Both switches accept files, globs and can be given multiple times, potentially combining both.
We'll see if we can implement this in the proposed way, but for now this is what we have 👍 |
is |
Unfortunately, no. I also would not consider that a viable candidate and do not know of any tool accepting a cumulative option like that. How you would you even parse that? (honest question?) |
Being able to pass a list of files would be really useful for pre-commit hooks. |
@prem-prakash That is possible, please see this comment.
|
See this comment #4 (comment) |
I am sorry, but I already replied to that comment, urging the author to state how that should work. I would pose the same question to you: How would the OptionParser be able to parse this unambiguously? You could also point out tools that work this way, so we could look up how they do it. 👍 |
Hi Rene, sorry for insisting. In fact, OptionParser is a bit limited in that it cannot deal with a list of values for an option in another way than repeating the option prefix. Thanks for your attention. |
I did not want to discourage you. ✌️ My understanding is that it is more or less trivial to control the files in a scripting environment like BASH: function run_credo {
cmd=(mix credo)
for file in "$@"; do
cmd+=("--files-included" "$file")
done
command "${cmd[@]}"
}
run_credo `ls lib/*.ex` I am just curious how we could provide a more convenient version that is as precise as the culmulative option solution while making it more approachable for non-scripting experts. |
@rrrene |
@alex9spiridonov Rubocop does not work in the discussed fashion. Please re-read the discussion above 👍 |
@rrrene yes it does |
@prem-prakash there is no need to be passive agressive here. The option discussed above was to have a single option that receives the space-separated list of files (see the linked and quoted comment as well as the discussion re: OptionParser). You are posting a screenshot of a program that receives a list of files as arguments. I'm sorry, but that is not the same thing. |
@rrrene sorry, it was not my intention to sound passive-aggressive. |
@prem-prakash maybe it will be useful for you. - CHANGED_FILES=$(git diff-tree -r --no-commit-id --name-only --merge-base --diff-filter=d origin/master HEAD)
- FILES_INCLUDED=""
- for f in $(echo $CHANGED_FILES | tr ";" "\n") ; do FILES_INCLUDED="$FILES_INCLUDED --files-included $f" ; done
- if [ ! -z "$CHANGED_FILES" ] ; then echo $FILES_INCLUDED | xargs sudo -E mix credo --strict ; fi |
Note to future readers: credo 1.7 now supports this out of the box |
While trying to add credo analysis in my
pre-commit
git hook on staged files, I noticed that actually only the first file of the list was anaylzed. (Credo :0.6.1
, Elixir :1.4.1
, default.credo.exs
)So being able to do something like :
mix credo [options] file1.exs file2.ex file3.ex
would be really nice imo ! :)The text was updated successfully, but these errors were encountered: