Repository navigation
Enable readability-braces-around-statements in clang-tidy - #481
Conversation
Enables the readability-braces-around-statements clang-tidy check on this repo's shared baseline config, matching what was enabled in DataDog/dd-trace-cpp#390. Uses the `ShortStatementLines: 1` CheckOption (same approach the dd-trace-cpp maintainer landed after review, so a one-line guard clause such as `if (cond) return;` stays exempt) rather than forcing braces onto every brace-less statement unconditionally. Audited nginx-datadog's largest src/ files for pre-existing multi-line brace-less if/while/for bodies; none were found, so this should not break the unscoped `make lint` / bin/lint.sh CI job.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 1953c38 | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6177271165
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Overview
Enables the
readability-braces-around-statementsclang-tidy check on this repo's shared.clang-tidybaseline, bringing nginx-datadog in line withDataDog/dd-trace-cpp#390(merged), which enabled the same check for dd-trace-cpp.Motivation
Recurring review theme: missing braces on single-line if/return bodies. This C++ code-review pattern (a human reviewer,
xlamorlette-datadog, asking for braces around single-statementif/returnbodies) has recurred across this automation's analysis window in at least two distinct PRs:DataDog/dd-trace-cpp#286(review comment 2906887472)DataDog/dd-trace-cpp#295(review comment 3046662390)DataDog/dd-trace-cpp#313(review comment 3184077016, accepted — fixed in commitd4c0de6)DataDog/httpd-datadog#62(review comment 3123418541, accepted — fixed in commit8694cdf, adding braces to multi-line if/return in tracing hooks)Observed in 4 of the recurring-theme-qualifying PRs across dd-trace-cpp and httpd-datadog; this is the first PR applying it in nginx-datadog specifically, since the pattern is generic C++ style (not nginx-specific idiom) and nginx-datadog shares the same
.clang-tidybaseline file as the other two repos.This rule is enforceable with a built-in
readability-*clang-tidy check with a low false-positive rate, and is the preferred automatable fix for this category of review feedback per the team's standing automation policy.Approach note (adjusted per prior maintainer feedback)
When
dd-trace-cpp#390first enabled this check with a blanket brace-everywhere configuration, the maintainer (xlamorlette-datadog) requested a narrower approach: add thereadability-braces-around-statements.ShortStatementLines: 1CheckOptionso a one-line guard clause likeif (cond) return;stays exempt, rather than forcing braces onto every brace-less statement unconditionally (see issue comment 6367804742; the maintainer personally pushed commit6d6d377implementing this before merging). This PR uses that sameShortStatementLines: 1option from the start.Additional context (automated analysis)
src/C++ files (the largest files, includingngx_http_datadog_module.cpp,request_tracing.cpp,datadog_context.cpp,datadog_variable.cpp,tracing_library.cpp,datadog_handler.cpp,datadog_conf.cpp,nginx_package_abi.cpp,ngx_script.cpp,ngx_event_scheduler.cpp,ngx_logger.cpp) for pre-existing multi-line brace-lessif/while/forbodies that would trip this check; none were found.bin/lint.sh/make lintis not diff-scoped (it lints all ofsrc/), so this check only being enabled where the codebase is already clean avoids breaking CI.Checks:list consumed bybin/lint.sh, which is the blocking lint job invoked viamake lint(documented indoc/development.md).Contributor Checklist