Skip to content

Full-codebase formatting, clang-tidy, and include unification - #213

Merged
skal65535 merged 5 commits into
webmproject:mainfrom
hasinoff:clang-format-tidy
Oct 2, 2026
Merged

skal65535 merged 5 commits into
webmproject:mainfrom
hasinoff:clang-format-tidy

Conversation

@hasinoff

@hasinoff hasinoff commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This change applies a comprehensive pass of clang-format and clang-tidy cleanups across the repository, unifies C standard library header inclusions, and introduces automated CI formatting enforcement.

Summary of Changes:

  1. Clang-Format:

    • Re-formatted all source files, examples, and tests using standard Google C++ formatting.
    • Formatted kZigzag, kInvZigzag, and kDefaultMatrices in src/quantize.cc with exactly 8 elements per row, protected by // clang-format off / // clang-format on blocks to preserve matrix layout.
    • Kept the large 114k lookup table in src/score_7.cc protected from reformatting.
  2. Automated CI Format Check (.github/workflows/ci-format-check.yml):

    • Added a standalone GitHub Actions workflow running RafikFarhad/clang-format-github-action@v7 to enforce clang-format on all .cc and .h files across push and PR events, with automatic PR concurrency cancellation.
  3. Clang-Tidy Configuration (.clang-tidy):

    • Added a portable .clang-tidy file enabling standard upstream checks: bugprone-*, google-*, misc-*, modernize-*, performance-*, portability-*, and readability-*.
    • Applied cleanups for namespace closing comments, redundant void arguments, nullptr modernizations, explicit constructors, and unused declarations.
  4. Include Cleanup (IWYU pass):

    • Added missing direct headers for used symbols (e.g., <stdlib.h>, <assert.h>, <algorithm>, <vector>).
    • Pruned unused includes across src/ and examples/.
    • Configured IWYU pragma: export in src/sjpegi.h (for simd.h, sjpeg.h, bit_writer.h) and keep pragmas in examples/vjpeg.cc to keep automated include analyzers clean in future PRs.
  5. Header Style Unification:

    • Unified all C standard library includes to use the <*.h> style across the codebase (e.g., <stdint.h>, <stdlib.h>, <assert.h>, <math.h>, <limits.h>), matching existing predominant repository usage.

Testing:

  • Verified all targets compile cleanly (cmake --build build -j).
  • Passed all local test suites with 100% success rate (unit_test, test_cmd, test_png_jpg).
  • Clean clang-tidy run across all translation units.
  • Verified CI Format Check passes green on GitHub Actions.

@vrabaud

vrabaud commented Sep 30, 2026

Copy link
Copy Markdown

@skal65535

Copy link
Copy Markdown
Collaborator

@hasinoff

Copy link
Copy Markdown
Contributor Author

Hi, thx. How about adding a test to the CI ? E.g. https://github.com/webmproject/libsmpte2094-50/blob/a8ec3fc61b9ed0719b32a198816804dbb3b6da82/.github/workflows/ci-format-check.yml#L13-L22

yes please!

Good call, done.

@skal65535

Copy link
Copy Markdown
Collaborator

i don't agree with all the clang formatting (like when semantically-close params are decoupled. e.g. "int width, int height") but there's certainly a value in unified and automated clang-format treatment. submitting.

@skal65535
skal65535 merged commit 7ad803e into webmproject:main Oct 2, 2026
11 checks passed
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