Comments (6)
Actually, it only seems to exit with code 1 through pre-commit. If I invoke clang-tidy
directly, it shows the warnings were suppressed but exits with code 0.
$ clang-tidy --fix -p cmake-build-debug src/main.c
2816 warnings generated.
Suppressed 2816 warnings (2816 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
$ echo $?
0
clang-tidy...............................................................Failed
- hook id: clang-tidy
- exit code: 1
2816 warnings generated.
Suppressed 2816 warnings (2816 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
repos:
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.3
hooks:
- id: clang-format
args: [-i, --style=file]
- id: clang-tidy
args: [--fix, -p=cmake-build-debug]
My solution for now is to use a local hook:
repos:
- repo: local
hooks:
- id: clang-tidy
name: clang-tidy
description: Statically analyse files with clang-tidy.
entry: clang-tidy --fix -p=cmake-build-debug
language: system
types: [c]
Frankly, I don't really see what the clang-tidy hook here has to offer over the above.
from pre-commit-hooks.
What version of llvm are you using? What OS are you on? The test ok file uses <stdio.h> and the test passes. I'll take a look at it.
from pre-commit-hooks.
Can you provide your src/main.c
as well (or a link to the repo that has it)? I'm not able to replicate this on Linux or Macos.
from pre-commit-hooks.
Adding some tests for double-dash arguments --
--std=c++20
, I got a test that failed (try using -- args with your local hook). I'm guessing the default language target on your system is higher than mine?
Most recent commit is 661e54b - can you set rev to that and see if you still have issues?
from pre-commit-hooks.
Sorry for a late response. I did get together a minimal reproducible example, but I tried that new ref, and it indeed fixes the issue. I was going to point out that clang-tidy was outputting to stderr and the hook always failed if it saw anything in stderr, but you caught onto that already.
For posterity, I suppose I'll attach the example anyway since I already made it. It can be reproduced through Docker.
I'm guessing the default language target on your system is higher than mine?
I don't know; I specify it through CMake. I thought clang-tidy somehow determines the language target by reading compile_commands.json
.
from pre-commit-hooks.
Looks like your language target is C 99. I added this as a test in tests/test_iss36.py.
Thanks for providing your example files.
from pre-commit-hooks.
Related Issues (20)
- Add ability to only lint/analyze committed lines
- Resolve Tooling and support multiple version of clang-tidy HOT 3
- run clang-format againt own .clang-format file HOT 2
- file regex not read from the configuration file HOT 10
- clang-format stops working when using --version HOT 5
- oclint multiple execution and inability to see the output HOT 4
- Class ClangTidyCmd disregards its `args` parameter HOT 2
- Incorrect order of arguments for include-what-you-use?
- can I add few more arguments for clang-format and clang-tidy? HOT 2
- clang-tidy file exclude pattern ignored
- LLVM really includes clang-format and clang-tidy?
- clang format failed HOT 2
- include-what-you-use does not fail
- add_if_missing() does not allow multiple --suppress arguments HOT 2
- Configurable `uncrustify` executable path for the uncrustify hook HOT 2
- clang-tidy: for the -p option: may not occur within a group! HOT 1
- Use a clang-format file that isn't at the root of the repo
- Mistake in comment ? HOT 1
- file not found [clang-diagnostic-error] #include "lib1.h" ^~~~~~~~ HOT 2
- Example hook config for vala
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pre-commit-hooks.