BLD: add more static analysis#31661
Conversation
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
| @@ -0,0 +1,246 @@ | |||
| #!/usr/bin/env python3 | |||
| """ | |||
| Run clang-tidy on Matplotlib's C/C++ and Objective-C sources. | |||
There was a problem hiding this comment.
I'm not sure this script is fully necessary; meson will create a clang-tidy target for you (but only if you have .clang-tidy in the root), so you just need to move it, make an editable install, and run ninja -C build/cp313 clang-tidy or similar
There was a problem hiding this comment.
I think it is still useful for filtering out warnings from the Agg source, but this can indeed be greatly simplified.
There was a problem hiding this comment.
I simplified this, still think it is useful to have to automate creating a build directory just for clang-tidy and for filtering the output.
These were false positives, but add code to give the analyzer a hint + asserts in a debugging build rather than NOLINT to be defensive. Aided by 🤖
When for no-change to code with the qhull wrapper rather than adjusting the code. Aided by 🤖
Fixes an issue found by clang-tidy Aided by 🤖
Simplified at Elliott's suggestions Aided by 🤖
Added exceptions for things it thinks are questionable but we are OK with doing. Aided by 🤖
Aided by 🤖
Aided by 🤖
1c966c2 to
050c2e8
Compare
|
This runs zizimor twice (once in its own job, once in the prek job). I think that is OK, particularly because its own job also has a cron attached to it, but dropping the action in favor of just the prek invocation would also be fine. |
The separate job also has a token and should be able to run more checks, I think? |
| if current: | ||
| groups.append(current) | ||
| current = [line] | ||
| else: | ||
| current.append(line) | ||
|
|
||
| if current: | ||
| groups.append(current) |
There was a problem hiding this comment.
You can just append when you create it.
| if current: | |
| groups.append(current) | |
| current = [line] | |
| else: | |
| current.append(line) | |
| if current: | |
| groups.append(current) | |
| current = [line] | |
| groups.append(current) | |
| else: | |
| current.append(line) |
| hooks: | ||
| - id: shellcheck | ||
| - repo: https://github.com/zizmorcore/zizmor-pre-commit | ||
| rev: a4727cbbcd26d7098e96b9cb738169b59711ae51 # frozen: v1.24.1 |
There was a problem hiding this comment.
| rev: a4727cbbcd26d7098e96b9cb738169b59711ae51 # frozen: v1.24.1 | |
| rev: 04a94ec45c8e92de281e3cc55754eb6d9db526a1 # frozen: v1.25.1 |
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
greglucas
left a comment
There was a problem hiding this comment.
Honestly not very many issues, most very minor ignores, so that is good to see!
Overall looks good to me and definitely something good to have in CI checks as well. I'm not sure if there are any comments @QuLogic is still waiting on so I'll hold off merging, but feel free to self-merge if you think you've already addressed everything.
| # These workflows use pull_request_target solely to obtain write access | ||
| # for API operations (labeling, commenting) on fork PRs. None of them | ||
| # check out or execute any PR-supplied code. |
There was a problem hiding this comment.
I wonder if it is possible for zizmor to identify that we don't use actions/checkout within the workflows?
It would be nice to prove that no one changes these or we aren't doing this on accident. There are just so many vulnerabilities with the pull_request_target issues these days...
…661-on-v3.11.x Backport PR #31661 on branch v3.11.x (BLD: add more static analysis)
PR summary
This adds more static analysis to our CI / prek config.
clang-tidyon c/c++/objectiveC code (and fix or ignore issues found). This found a couple of real issues and will only run on CI (+ a helper script to run it locally). The dependencies are too heavy to try and launder through prek's virtual environments.pull_request_targetand a couple of places we allow caching. Also enabled cooldown windows on our dependabot config. This also flagged we had a redundant checkout step inrun ruff on our checked in notebooks as wellOur exsiting ruff config hits this alreadyNot reflected in the commits here, but I did look at https://github.com/PyCQA/bandit but every single thing it flagged was a false positive (either flagging things like
execin the plot directive or being too simplistic to notice that we had already mitigated the thing it was flagging in the code).AI Disclosure
I started from the prompt
with opus 4.6 and then pushing on addressing the coverage with a mix of opus 4.6 and sonnet 4.6. I reviewed everything as I committed it and took a very heavy editing pass at the initial version of the documentation.
PR checklist