pre-commit: args after -- fail
Problem
Occasionally it is necessary to use --
to signify options that take an argument. When --
is used, any file arguments are ignored.
Description
I am using oclint
, which identifies potential problems in c code. --
is required to specify compiler options. This is my current configuration:
[-- skipped for brevity --]
- repo: local
hooks:
- id: oclint
name: oclint
description: Find warnings/errors in C/CPP code
entry: oclint
types: [c]
pass_filenames: true
args: [
-enable-clang-static-analyzer,
-enable-global-analysis,
--,
-report-type=json,
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON,
]
language: system
When running on a valid c file, I get this output:
oclint...................................................................Failed
hookid: oclint
oclint: Not enough positional command line arguments specified!
Must specify at least 1 positional argument: See: /usr/local/bin/oclint -help
Solution
Looking at the code, it looks like you are appending file arguments to the end instead of infixing them before --
. A pull request that fixes this will be coming in a few.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (8 by maintainers)
No problem. Thanks for the context.
we used to use a
[wontfix]
label but found that it frustrated question askers so I removed it a while back 🤷♂I just hit the same challenge while working with Angular-cli’s built-in
ng lint
program. Thanks for leaving the notes as they proved helpful in getting pre-commit-nglint working. 😄The
--
issue may pop up again, but given that it’s mostly used with C/C++ compilation, my hooks will likely obviate the need for further changes.