Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 1.96 KB

File metadata and controls

60 lines (43 loc) · 1.96 KB

ITK Enforced Code Style

Style rules enforced by pre-commit hooks and CI. Violations block commits and PRs. See compiler-cautions.md section 12 for KWStyle-specific pitfalls.

First-Time Setup

./Utilities/SetupForDevelopment.sh

Configures git hooks (pre-commit clang-format, commit-msg KWStyle check) and remote setup. Required before your first commit.

C++ Formatting (clang-format)

clang-format 19.1.7 is enforced automatically by the pre-commit hook.

Utilities/Maintenance/clang-format.bash --modified   # Format modified files only

The hook modifies files in place; re-stage and recommit if it changes anything. Do not use --no-verify to bypass — the format check exists to keep CI green.

KWStyle (commit messages and doxygen)

The kw-commit-msg.py hook enforces:

KWStyle also checks that every header has the doxygen \class tag. See compiler-cautions.md section 12a for the enum class pitfall where KWStyle requires \class on enum declarations.

Naming Conventions

Entity Convention Example
Classes PascalCase MedianImageFilter
Variables camelCase imageSize
Member variables m_ prefix m_Radius
Template parameters T or V prefix TInputImage, VDimension
Macros ALL_CAPS ITK_UPPERCASE_MACRO

Style Rules

  • constexpr instead of #define for constants
  • Smart pointers for all ITK objects: auto image = ImageType::New();
  • American English spelling throughout
  • Doxygen comments use backslash style: \class, \brief
  • No using namespace in headers

CI/CD