Skip to content

Qual(ci): Update pre-commit hooks, caching - #4579

Open
mdeweerd wants to merge 1 commit into
uncrustify:masterfrom
mdeweerd:pre-commit-ignore
Open

Qual(ci): Update pre-commit hooks, caching#4579
mdeweerd wants to merge 1 commit into
uncrustify:masterfrom
mdeweerd:pre-commit-ignore

Conversation

@mdeweerd

@mdeweerd mdeweerd commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

Qual(ci): Update pre-commit hooks, caching

  • Cppcheck Upgrade: Updated cppcheck to the latest version (2.21.1)
  • Cache Management: Refined cache keys to explicitly incorporate the Cppcheck version
  • Hooks: Updated beautysh and codespell

@mdeweerd mdeweerd changed the title chore: Remove error suppression for nullPointerRedundantCheck(src/uncrustify.cpp) chore: Remove error suppression for cppcheck Nov 24, 2025
@mdeweerd

Copy link
Copy Markdown
Contributor Author

FYI, the notices that are remaining:

src/uncrustify.cpp(1862): warning (nullPointerRedundantCheck): Either the condition 'ref=ref->GetPrev()' is redundant or there is possible null pointer dereference: ref.
src/keywords.cpp(199): style (unsignedLessThanZero): Checking if unsigned expression 'len' is less than zero.
src/keywords.cpp(217): error (uninitvar): Uninitialized variables: &key.type, &key.lang_flags
src/tokenizer/combine_fix_mark.cpp(1420): style (knownConditionTrueFalse): Condition 'tmp2->IsNotNullChunk()' is always false
src/align/var_def_brace.cpp(129): style (knownConditionTrueFalse): Condition 'pc->IsPreproc()' is always false
src/tokenizer/combine_labels.cpp(285): style (knownConditionTrueFalse): Condition 'tmp->IsNullChunk()' is always false
src/unc_text.cpp(43): style (constParameterReference): Parameter 'c0' can be declared as reference to const
src/align/var_def_brace.cpp(129): style (knownConditionTrueFalse): Condition 'pc->IsPreproc()' is always false
src/tokenizer/mark_question_colon.cpp(147): style (knownConditionTrueFalse): Condition 'pc2->IsNotNullChunk()' is always false
src/tokenizer/mark_question_colon.cpp(102): style (knownConditionTrueFalse): Condition 'colon_found' is always false

@guy-maurel

Copy link
Copy Markdown
Contributor

I will provide the necessary changes

@mdeweerd

Copy link
Copy Markdown
Contributor Author

The checks can already be enabled in the master branch because I've added suppressions to #4494 so that the github actions does not show a failure.

This PR that re-enables these cases in the reports can then be updated with updates from the master branch until all notices are fixed (and this PR can be used to verify it).

@guy-maurel

Copy link
Copy Markdown
Contributor

PR #4581 is a bug fix proposal.
Please test it and report.

@gmaurel

gmaurel commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

@mdeweerd

Copy link
Copy Markdown
Contributor Author

@gmaurel

I rebased and the notices below remain.

The followiing could be resolved using a comma operator (ref=ref->GetPrev(), <rest of condition>). The code "as-is" tests that the new ref is not null.

  • src/uncrustify.cpp(1862): warning (nullPointerRedundantCheck): Either the condition 'ref=ref->GetPrev()' is redundant or there is possible null pointer dereference: ref.

These need code review/fixes:

  • src/tokenizer/combine_fix_mark.cpp(1420): style (knownConditionTrueFalse): Condition 'tmp2->IsNotNullChunk()' is always false
  • src/align/var_def_brace.cpp(150): style (knownConditionTrueFalse): Condition 'pc->IsPreproc()' is always false
  • src/tokenizer/combine_labels.cpp(285): style (knownConditionTrueFalse): Condition 'tmp->IsNullChunk()' is always false

@gmaurel

gmaurel commented Feb 5, 2026

Copy link
Copy Markdown
Collaborator

we need to repair, step by step untill we get info from cppcheck.
I'll change the files.

@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch 2 times, most recently from cc94ba0 to c4d7d5e Compare February 6, 2026 11:48
@mdeweerd

mdeweerd commented Feb 21, 2026

Copy link
Copy Markdown
Contributor Author

I fixed a cppcheck notice in md5.cpp (argument can be constant).

A new notice was introduced due to changes, probably #4612 (@PoeticPete ).

src/tokenizer/mark_question_colon.cpp(156): style (knownConditionTrueFalse): Condition 'colon_found' is always false

And I added a definition of "UNCRUSTIFY_VERSION" as an argument to cppcheck to avoid a notice I encountered locally.

@gmaurel gmaurel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not make any change at the file [.pre-commit-config.yaml
I am working on it, I need about 10 days until I am ready.
Thanks

@mdeweerd

mdeweerd commented Feb 21, 2026

Copy link
Copy Markdown
Contributor Author

Do not make any change at the file [.pre-commit-config.yaml I am working on it, I need about 10 days until I am ready. Thanks

This PR is mainly to verify rhe results of cppcheck.
If you can add the extra option for cppcheck that is useful.

@guy-maurel

Copy link
Copy Markdown
Contributor

Sorry for the noise!
I don't need any 10 days.
Nobody needs to wait of me.
Sorry

@mdeweerd

Copy link
Copy Markdown
Contributor Author

Sorry for the noise! I don't need any 10 days. Nobody needs to wait of me. Sorry

Don't worry, I took it as a notice to not make too many changes to the pre-commit configuration as you are making more in-depth changes). I prefer that.

@mdeweerd

Copy link
Copy Markdown
Contributor Author

Result of local execution:

src/tokenizer/mark_question_colon.cpp(156): style (knownConditionTrueFalse): Condition 'colon_found' is always false
src/uncrustify_emscripten.cpp(59): information (missingInclude): Include file: "uncrustify_version.h" not found.
src/uncrustify_emscripten.cpp(176): performance (passedByValueCallback): Function parameter 'tag' should be passed by const reference. However it seems that '_add_keyword' is a callback function.
src/uncrustify_emscripten.cpp(226): performance (passedByValueCallback): Function parameter 'name' should be passed by const reference. However it seems that 'reset_option' is a callback function.
src/uncrustify_emscripten.cpp(252): performance (passedByValueCallback): Function parameter 'name' should be passed by const reference. However it seems that 'set_option' is a callback function.
src/uncrustify_emscripten.cpp(252): performance (passedByValueCallback): Function parameter 'value' should be passed by const reference. However it seems that 'set_option' is a callback function.
src/uncrustify_emscripten.cpp(294): performance (passedByValueCallback): Function parameter 'name' should be passed by const reference. However it seems that 'get_option' is a callback function.
src/uncrustify_emscripten.cpp(116): style (constParameterReference): Parameter 'o' can be declared as reference to const

@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch from c0bd130 to 2784a13 Compare March 1, 2026 21:56
@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch 2 times, most recently from 20bcc43 to eae2dc4 Compare April 14, 2026 20:23
@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch 2 times, most recently from 9b1a792 to 4505c20 Compare May 8, 2026 09:41
@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch from 4505c20 to f25359e Compare June 7, 2026 08:07
@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch 2 times, most recently from c205e5e to b33efee Compare June 19, 2026 16:15
@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch from 540a9d7 to 237f532 Compare July 12, 2026 10:39
@mdeweerd

Copy link
Copy Markdown
Contributor Author

FYI: I've submitted a PR to fix the cppcheck caching issue with the pre-commit hook.
A temporary solution could be to point to my fork for this fix.

@gmaurel

gmaurel commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

I have finished all the necessary changes.
The test with the file .pre-commit-config.yaml works pretty well for cppcheck.

May I close your call?

@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch from 237f532 to 7caf67c Compare August 9, 2026 16:28
*   **Cppcheck Upgrade:** Updated cppcheck to the latest version (2.21.1)
*   **Cache Management:** Refined cache keys to explicitly incorporate the Cppcheck version
*   **Hooks:** Updated beautysh and codespell
@mdeweerd
mdeweerd force-pushed the pre-commit-ignore branch from 7caf67c to 8ccf8b8 Compare August 9, 2026 17:08
@mdeweerd mdeweerd changed the title chore: Remove error suppression for cppcheck Qual(ci): Update pre-commit hooks, caching Aug 9, 2026
@mdeweerd

mdeweerd commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@gmaurel I've updated the description of this PR, and squashed my commits.

I am waiting for a PR for the cppcheck hook fixing caching to be accepted in that hook's release. We could temporarily point the hook to my fork of pre-commit-hooks.
This will allow proper caching and increase the speed of the analysis - the "official" version for the cppcheck hook analyses the files one by one, rather than through a single cppcheck call and breaks any caching opportunity.
-> Do we wait, or point to my fork (when integrated we can point back to the upstream)?

The other updates here are the upgrade of some of the other pre-commit hook versions and the update of cppcheck to the latest version which brings some new cases:
And that it enables cppcheck for the big files - which will not be an issue when caching actually works. If this is to be integrated before, I'll remove it again.

src/token_is_within_trailing_return.cpp(16): style (constParameterPointer): Parameter 'pc' can be declared as pointer to const
src/unc_tools.cpp(63): style (constParameterPointer): Parameter 'pc_sub' can be declared as pointer to const
src/unc_tools.cpp(833): style (constVariablePointer): Variable 'pc_saved' can be declared as pointer to const
src/detect.cpp(155): style (constVariablePointer): Variable 'pc' can be declared as pointer to const

Messages like the follwoing are related to the caching limitation of the current cppcheck hook: nofile(0): error (internalError): failed to load '.cache/cppcheck/enum.a1' from '.cache/cppcheck/files.txt'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants