跳到正文
cccskills
免费在 GitHub 公开

be-code-style

Format C++ code in the BE and Cloud modules using the project's clang-format v16 rules. Use the provided scripts to fix formatting or check for violations without changing files, then review the resulting differences before committing.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Fix BE (C++) code formatting issues using clang-format

查看安装方法

适用场景

  • Format BE or Cloud C++ code before committing
  • Fix formatting failures reported by CI
  • Check formatting without modifying files
  • Find the required clang-format v16 executable

包含的文件(1)

  • SKILL.md2.8 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

What I do

Fix C++ code formatting issues in the BE and Cloud modules using the project's clang-format configuration (v16).

When to use me

  • Before committing BE/Cloud C++ code changes
  • When CI reports clang-format failures
  • When you need to check or fix C++ code style

Prerequisites

You need to confirm that the major version of the called clang-format is 16. If the current environment's default does not meet this requirement, try the following:

  1. If .vscode/settings.json exists, use the clang-format.executable item in it.
  2. If it is a worktree directory, use the .vscode/settings.json from the main directory.
  3. Check the path to the compiler toolchain by trying to find it from the PATH environment variable, the current directory, and the main directory's custom_env.sh. Look for a clang-format with the major version number 16 in that path and its parent directory.

Procedure

Step 1: Auto-fix formatting

Run the project's formatting script, which enforces clang-format v16:

build-support/clang-format.sh

This formats all C++ files under be/src, be/test, cloud/src, cloud/test in-place, respecting .clang-format and .clang-format-ignore.

Important: Always use this script instead of invoking clang-format directly. The script checks that clang-format version 16 is installed and exits with an error if the wrong version is found. Using a different version will produce inconsistent formatting.

Step 2: Check-only (no modification)

To verify formatting without modifying files:

build-support/check-format.sh

This outputs a diff of any formatting violations and exits non-zero if there are any.

Step 3: Review and commit

After running clang-format.sh, review the changes with git diff to verify only formatting was changed, then stage and commit.

Key Configuration

FilePurpose
.clang-formatMain formatting rules (Google-based, 100 col, 4-space indent)
.clang-format-ignoreFiles excluded from formatting (third-party, generated)
build-support/run_clang_format.pyPython wrapper for parallel execution

Excluded Directories

The following are excluded from formatting (see .clang-format-ignore):

  • be/src/apache-orc/*, be/src/clucene/*, be/src/gutil/*
  • be/src/glibc-compatibility/*
  • Specific third-party vendored files (mustache, sse2neon, utf8_check)
  • cloud/src/common/defer.h

Troubleshooting

ProblemSolution
clang-format not foundInstall clang-format v16 or set CLANG_FORMAT_BINARY env var
version is not 16Install clang-format v16; on macOS: brew install llvm@16
Files not being formattedCheck .clang-format-ignore for exclusions

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Run clang-tidy static analysis, which checks code without executing it, on added or modified BE and Cloud C++ files. Focus diagnostics on changed lines, investigate bug, performance, and readability warnings, and verify fixes with another check.

中文简介正在准备中。当前显示英语简介。

  • Check changed C++ code before committing
  • Investigate clang-tidy warnings reported by CI
  • Review changes against a specific branch
apache/doris1.6万2026年10月18日 更新

Review Doris code changes using project-specific checklists for data correctness, concurrency, memory safety, compatibility, performance, and tests. Trace related code paths and explain findings with concrete failure scenarios, using query plan trees when reviewing optimizer behavior.

中文简介正在准备中。当前显示英语简介。

  • Review newly completed Doris code changes
  • Check concurrency and memory management in related code paths
  • Assess compatibility and test coverage before merging
apache/doris1.6万2026年10月18日 更新

Prepare a clean Doris package and run Docker regression tests, which check whether changes break existing behavior. Restore configuration and startup files from Git, build the test image, and investigate failures using configuration checks and runtime logs.

中文简介正在准备中。当前显示英语简介。

  • Run Docker regression tests before submitting Doris changes
  • Test without local configuration changes affecting results
  • Investigate missing test suites or startup failures
apache/doris1.6万2026年10月18日 更新

Diagnoses and fixes Java style violations in the FE module using Checkstyle, a tool that checks coding rules. It interprets errors, applies the project's formatting and import restrictions, and reruns checks to verify fixes.

中文简介正在准备中。当前显示英语简介。

  • Checking FE Java changes before committing
  • Fixing build failures caused by Checkstyle violations
  • Understanding project-specific style and import rules
apache/doris1.6万2026年10月18日 更新

查看 apache 的全部技能

报告此技能的问题