-
Notifications
You must be signed in to change notification settings - Fork 160
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
Remove types_or from shellcheck hook #187
Conversation
cc @roberth |
9503745
to
2f189a7
Compare
Not all shells are supported by shellcheck. I think we're going to need some tests for shellcheck. so we can grep our build failures easily |
This made the pre-commit configuration work with shell files. Tested on macOS 10.15.7 (Intel i7) and 12.6 (Apple M1 Max) using both bash and zsh
2f189a7
to
ba6cdd5
Compare
I see. I guess one option would be to have different configurations based on the architecture? Or do you have any other idea? |
For anyone who read here. The current situation is if you have a
If you have a file ends with some known extension (e.g. some-bash.sh), it will not read the file content and skip shebang checks. Thus it won't have Another thing to notice is that executable attr will be treated differently. If your script is not executable it won't be checked if it does not have proper extension: https://github.com/pre-commit/identify/blob/cdad607f6a10bda406f7836568edbfd74eb4c6af/identify/identify.py#L62 All of these are really really unexpected, and I don't think this make the fact that file will be missing tags clear enough. For now my solution will be just create a custom hook to fit my project needs, as all of my script are based on bash. However I do agree that make it configurable for now would be great, or adding some note in the |
I think most projects do the sensible thing and
We should support these and perhaps not worry too much about other shells. Perhaps we could move the current solution behind a |
Right now the most annoying problem would be any .sh file, no matter what shebang it has, will be skipped, and I don't think this is expected behavior. This is a common convention for existing projects, even though it might now be a good one. But changing all them needs to put lots of effort Related reading about .sh convention: https://stackoverflow.com/a/27824204 |
I agree with the linked explanation, and I should have added that I intended my bullet points to be mutually exclusive. To summarize
pre-commit's
So for now we could just match |
@roberth I believe either of your approach is feasible --- imo identity should allow further exploration of shell type when extension matched (continue to check shebang on shell type), as shell type file are typically not too many and reading them should be feasible in most cases but an option to control the behavior would be great. However this is basically pushing the problem to upstream. For now I think we agree that current hook filter is too strict and make it less useful in most situations (.sh executable file was skipped). My simple approach to address this would be have a setting to switch between strict rule(current one) and relaxed rule(match any shell), and default to strict one so existing behavior won't break, but user may easily switch in between. This imo would cover most of the real world situation. |
oops I did not see this when I opened up #339. Now that its been merged though this can be closed right? |
@mmlb I believe so, thanks for the PR! |
this is fixed on master |
This made the pre-commit configuration work with shell files. Otherwise it works only with
.bash
files. I couldn't really figure out why that's the case by looking at how pre-commit filtering works.Tested on macOS 10.15.7 (Intel i7) and 12.6 (Apple M1 Max) using both bash and zsh.