Skip to content

Auto-fix Support for clang-tidy #199

@shenxianpeng

Description

@shenxianpeng

Problem

Currently, the clang-tidy hook only reports issues but does not apply
fixes. Users must manually run clang-tidy --fix or interpret the
suggestions themselves. This is inconsistent with the clang-format hook,
which already auto-formats files in place.

Proposed Solution

Add an --fix argument to the clang-tidy hook that passes -fix to
clang-tidy internally:

- id: clang-tidy
  args: [--checks=.clang-tidy, --fix]

This should be opt-in (not the default) since auto-fixing can be
destructive and requires a clean compilation database to work correctly.
Notes
∙ -fix requires a valid compile_commands.json in most cases.
∙ Should document that -fix-errors is also available for cases where
compiler errors exist alongside style issues.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions