Skip to content

style: format sources and normalize comment conventions#104

Merged
tkhquang merged 1 commit into
mainfrom
style/format-comment-conventions
Jun 11, 2026
Merged

style: format sources and normalize comment conventions#104
tkhquang merged 1 commit into
mainfrom
style/format-comment-conventions

Conversation

@tkhquang

@tkhquang tkhquang commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

Repo-wide formatting and comment-convention cleanup with supporting tooling. No library behavior changes: the build stays -Werror clean and the full test suite stays green (1389/1389).

Highlights:

  • clang-format 18 applied across all tracked C++ sources.
  • Comment markers normalized: trailing ///< member docs moved above the member, multi-line /// converted to /** */, and the "document the interface, comment the implementation" rule codified in AGENTS.md.
  • Two write-only dead members removed and four inaccurate technical comments corrected.
  • Markdown docs un-wrapped (no hard 80-column wrapping), with GitHub alerts and fenced code preserved.
  • New scripts/check_comment_style.py lint plus an advisory CI step guard the comment conventions; the IntelliSense config now points at the build's compile_commands.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added comment style enforcement tool for code quality checks.
  • Documentation

    • Updated contribution guidelines with clarified comment conventions and formatting standards.
    • Improved sanitizer documentation with Windows ASan constraints and configuration details.
    • Enhanced testing and hot-reload documentation for clarity.
  • Chores

    • Updated CI workflow configuration to validate comment formatting conventions.
    • Improved IDE/development environment configuration for consistent tooling setup.
    • Code formatting and documentation consistency improvements throughout codebase.

- Apply clang-format 18 across tracked C++ sources (no behavior change).
- Move trailing ///< member docs above the member; convert multi-line /// to /** */.
- Remove two write-only dead members (StringPool m_pool_size, Block slot_count).
- Fix four inaccurate comments (logger localtime_s, profiler overflow bound, bootstrap, platform).
- Un-wrap markdown docs (no hard 80-col wrap); codify comment and formatting rules in AGENTS.md.
- Add scripts/check_comment_style.py plus an advisory CI lint step.
- Point IntelliSense (c_cpp_properties.json) at the build's compile_commands.
@tkhquang tkhquang self-assigned this Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR is a comprehensive code formatting and documentation standardization pass. It introduces a new comment-style linter tool (scripts/check_comment_style.py), integrates it into CI, updates developer documentation and benchmarking guides, converts inline trailing Doxygen comments to preceding block comments across headers, refactors async logger slot tracking, and reformats lambda/function bodies throughout tests and implementation files without changing functional logic.

Changes

Formatting and Documentation Standardization

Layer / File(s) Summary
Comment style linter tool and CI integration
scripts/check_comment_style.py, .github/workflows/quality.yml, .gitignore
New Python script validates comment conventions across tracked C++ files; CI workflow integrates the linter as a new advisory step; .gitignore updated to exclude .claude/* and Python bytecode.
Developer documentation and guidelines
AGENTS.md, README.md, docs/tests/README.md
AGENTS.md expanded with clarified comment/style conventions, Windows ASan runtime/link guidance, and repository tooling reference; README.md badges and ASan text reflowed; test documentation updated with smoke project and release workflow descriptions.
Benchmark documentation updates
docs/analysis/event_dispatcher_bench_v3.1.0/README.md, docs/hot-reload/README.md
EventDispatcher v3.1.0 benchmark interpretation and methodology sections clarified with per-scenario explanations; hot-reload documentation global state reset and FAQ items reformatted with consistent bolding and emphasis.
Miscellaneous documentation rewording
docs/misc/asan-memory-scanner.md, docs/misc/hot-path-memory.md
ASan memory scanner and hot-path memory guidance reflowed with adjusted line breaks while preserving substantive content and existing recommendations.
Doxygen documentation formatting in public headers
include/DetourModKit/{anchors,async_logger,bootstrap,config,diagnostics,drift_manifest,event_dispatcher,hook_manager,input,input_codes,logger,memory,profiler,rtti_dissect,scanner}.hpp, src/{rtti_internal,scanner_internal}.hpp
Converts trailing inline ///< comments to preceding /// Doxygen-style comments across all public API headers; affects enums, structs, and members without changing signatures, fields, or default values.
Async logger pool slot tracking refactor
include/DetourModKit/async_logger.hpp, src/async_logger.cpp
Removes per-block slot_count tracking from StringPool::Block; replaces m_pool_size counter with m_heap_fallback_count; removes slot-count increments/decrements during claim/return operations while preserving free-list and constructed_mask logic.
Comment and documentation formatting in source files
src/{async_logger,config,input,input_intercept,logger,memory,platform,profiler,rtti,rtti_internal,scanner_cascade,scanner_internal,string_xref,win_file_stream,worker}.{cpp,hpp}
Reformats comments, documentation blocks, and whitespace across implementation files; adjusts line-wrapping in predicates and conditional expressions; removes or relocates inline comments without changing control flow or behavior.
Test code formatting and lambda restructuring
tests/{bench_event_dispatcher,bench_memory,bench_scanner,test_async_logger,test_bootstrap,test_code_constant,test_config,test_event_dispatcher,test_hook_manager,test_input,test_input_intercept,test_logger,test_memory_chain,test_profiler,test_rtti,test_rtti_dissect,test_rtti_reverse,test_scanner}.cpp
Reformats lambda expressions, function bodies, and test helpers across all benchmark and unit test files; splits single-line functions into multi-line definitions; adjusts brace/indentation placement without changing test logic, assertions, or measurement behavior.
VSCode IntelliSense configuration update
.vscode/c_cpp_properties.json
Replaces windows-gcc-x64 configuration with windows-msvc-x64; updates compiler path to cl.exe, adds MSVC debug build compile commands path, expands include directories with zydis/zycore dependencies, and updates preprocessor defines for Windows versioning and static library builds.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • tkhquang/DetourModKit#15: Both PRs modify StringPool free-slot bookkeeping in src/async_logger.cpp (slot-count removal vs. refactored claiming/deallocation).
  • tkhquang/DetourModKit#101: Both PRs extend .github/workflows/quality.yml with the new advisory comment-style checker step and integrate the same check_comment_style.py linter into CI.
  • tkhquang/DetourModKit#26: Main PR's AGENTS.md and README.md documentation updates build on the retrieved PR's initial addition of developer guidelines and correspondence structure.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
scripts/check_comment_style.py (2)

32-32: 💤 Low value

Static analysis hint (S607) is a false positive in this context.

The Ruff warning about using a partial executable path (git) is technically correct for general security hardening, but it's a false positive here. The script runs in trusted CI and developer environments where git is a required dependency and the PATH is controlled. Hardcoding a full path would reduce portability across platforms without meaningful security benefit in this context.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check_comment_style.py` at line 32, The Ruff S607 warning is a false
positive for using "git" via subprocess.check_output in this trusted script;
suppress it by adding an inline noqa to the call so the linter ignores this
case. Edit the line assigning files (the subprocess.check_output(["git",
"ls-files", "*.cpp", "*.hpp"], text=True).split()) and append a comment like "#
noqa: S607" to that statement to silence the warning while keeping portability
and behavior unchanged.

Source: Linters/SAST tools


36-36: 💤 Low value

Consider splitlines() for more robust line-ending handling.

Using splitlines() instead of split("\n") would handle different line-ending conventions (\r\n, \r, \n) more uniformly and is the idiomatic Python approach for splitting text into lines.

📝 Optional refinement
-        lines = handle.read().split("\n")
+        lines = handle.read().splitlines()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check_comment_style.py` at line 36, Replace the fragile
handle.read().split("\n") call with Python's line-splitting API: use
handle.read().splitlines() (or str.splitlines(keepends=True) if you
intentionally need to preserve newline characters) so the parsing in the lines
variable correctly handles CR, LF and CRLF line endings; update the use sites
that rely on lines accordingly (refer to the handle.read().split("\n")
occurrence and the lines variable in scripts/check_comment_style.py).
.vscode/c_cpp_properties.json (1)

3-35: ⚡ Quick win

Consider adding a MinGW configuration for dual-toolchain development.

The configuration now exclusively targets MSVC via cl.exe and the msvc-debug build directory. Since the project supports both MSVC and MinGW builds (per learnings), developers working with MinGW would need to manually switch configurations.

Adding a second configuration entry for MinGW would improve the developer experience for those using both toolchains.

🔧 Example MinGW configuration addition
{
  "configurations": [
    {
      "name": "windows-msvc-x64",
      "compileCommands": "${workspaceFolder}/build/msvc-debug/compile_commands.json",
      ...
    },
    {
      "name": "windows-mingw-x64",
      "compileCommands": "${workspaceFolder}/build/mingw-debug/compile_commands.json",
      "includePath": [
        "${workspaceFolder}/include",
        "${workspaceFolder}/src",
        "${workspaceFolder}/external/DirectXMath/Inc",
        "${workspaceFolder}/external/simpleini",
        "${workspaceFolder}/external/safetyhook/include",
        "${workspaceFolder}/build/mingw-debug/generated",
        "${workspaceFolder}/build/mingw-debug/_deps/zydis-src/include",
        "${workspaceFolder}/build/mingw-debug/_deps/zydis-build",
        "${workspaceFolder}/build/mingw-debug/_deps/zydis-src/dependencies/zycore/include",
        "${workspaceFolder}/build/mingw-debug/_deps/zydis-build/zycore"
      ],
      "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE",
        "WIN32",
        "_WINDOWS",
        "NOMINMAX",
        "SAFETYHOOK_NO_DLL",
        "WINVER=0x0A00",
        "_WIN32_WINNT=0x0A00",
        "ZYCORE_STATIC_BUILD",
        "ZYDIS_STATIC_BUILD"
      ],
      "compilerPath": "g++.exe",
      "cStandard": "c23",
      "cppStandard": "c++23",
      "intelliSenseMode": "windows-gcc-x64"
    }
  ],
  "version": 4
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.vscode/c_cpp_properties.json around lines 3 - 35, The current
c_cpp_properties.json only defines the MSVC config ("name": "windows-msvc-x64",
"compilerPath": "cl.exe") so add a second configuration object for MinGW (e.g.,
"name": "windows-mingw-x64") inside a top-level "configurations" array: set
"compileCommands" to the mingw build's compile_commands.json, mirror the MSVC
"includePath" and "defines" but replace MSVC-specific build folders with the
mingw equivalents (e.g., build/mingw-debug/generated,
build/mingw-debug/_deps/...), set "compilerPath" to "g++.exe" and
"intelliSenseMode" to "windows-gcc-x64", and ensure the file ends with the
"version": 4 field.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.vscode/c_cpp_properties.json:
- Around line 3-35: The current c_cpp_properties.json only defines the MSVC
config ("name": "windows-msvc-x64", "compilerPath": "cl.exe") so add a second
configuration object for MinGW (e.g., "name": "windows-mingw-x64") inside a
top-level "configurations" array: set "compileCommands" to the mingw build's
compile_commands.json, mirror the MSVC "includePath" and "defines" but replace
MSVC-specific build folders with the mingw equivalents (e.g.,
build/mingw-debug/generated, build/mingw-debug/_deps/...), set "compilerPath" to
"g++.exe" and "intelliSenseMode" to "windows-gcc-x64", and ensure the file ends
with the "version": 4 field.

In `@scripts/check_comment_style.py`:
- Line 32: The Ruff S607 warning is a false positive for using "git" via
subprocess.check_output in this trusted script; suppress it by adding an inline
noqa to the call so the linter ignores this case. Edit the line assigning files
(the subprocess.check_output(["git", "ls-files", "*.cpp", "*.hpp"],
text=True).split()) and append a comment like "# noqa: S607" to that statement
to silence the warning while keeping portability and behavior unchanged.
- Line 36: Replace the fragile handle.read().split("\n") call with Python's
line-splitting API: use handle.read().splitlines() (or
str.splitlines(keepends=True) if you intentionally need to preserve newline
characters) so the parsing in the lines variable correctly handles CR, LF and
CRLF line endings; update the use sites that rely on lines accordingly (refer to
the handle.read().split("\n") occurrence and the lines variable in
scripts/check_comment_style.py).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5a99320b-ab72-4883-9178-9401d5b3f9c5

📥 Commits

Reviewing files that changed from the base of the PR and between 8f76e99 and e65c79f.

📒 Files selected for processing (62)
  • .github/workflows/quality.yml
  • .gitignore
  • .vscode/c_cpp_properties.json
  • AGENTS.md
  • README.md
  • docs/analysis/event_dispatcher_bench_v3.1.0/README.md
  • docs/hot-reload/README.md
  • docs/misc/asan-memory-scanner.md
  • docs/misc/hot-path-memory.md
  • docs/tests/README.md
  • docs/tests/test_compile.cpp
  • include/DetourModKit/anchors.hpp
  • include/DetourModKit/async_logger.hpp
  • include/DetourModKit/bootstrap.hpp
  • include/DetourModKit/config.hpp
  • include/DetourModKit/diagnostics.hpp
  • include/DetourModKit/drift_manifest.hpp
  • include/DetourModKit/event_dispatcher.hpp
  • include/DetourModKit/hook_manager.hpp
  • include/DetourModKit/input.hpp
  • include/DetourModKit/input_codes.hpp
  • include/DetourModKit/logger.hpp
  • include/DetourModKit/memory.hpp
  • include/DetourModKit/profiler.hpp
  • include/DetourModKit/rtti_dissect.hpp
  • include/DetourModKit/scanner.hpp
  • scripts/check_comment_style.py
  • src/async_logger.cpp
  • src/config.cpp
  • src/config_watcher.cpp
  • src/input.cpp
  • src/input_intercept.cpp
  • src/input_intercept.hpp
  • src/logger.cpp
  • src/memory.cpp
  • src/platform.hpp
  • src/profiler.cpp
  • src/rtti.cpp
  • src/rtti_internal.hpp
  • src/scanner_cascade.cpp
  • src/scanner_internal.hpp
  • src/string_xref.cpp
  • src/win_file_stream.cpp
  • src/worker.cpp
  • tests/bench_event_dispatcher.cpp
  • tests/bench_memory.cpp
  • tests/bench_scanner.cpp
  • tests/test_async_logger.cpp
  • tests/test_bootstrap.cpp
  • tests/test_code_constant.cpp
  • tests/test_config.cpp
  • tests/test_event_dispatcher.cpp
  • tests/test_hook_manager.cpp
  • tests/test_input.cpp
  • tests/test_input_intercept.cpp
  • tests/test_logger.cpp
  • tests/test_memory_chain.cpp
  • tests/test_profiler.cpp
  • tests/test_rtti.cpp
  • tests/test_rtti_dissect.cpp
  • tests/test_rtti_reverse.cpp
  • tests/test_scanner.cpp
💤 Files with no reviewable changes (2)
  • tests/test_async_logger.cpp
  • src/scanner_cascade.cpp

@tkhquang tkhquang merged commit 0a8b595 into main Jun 11, 2026
4 checks passed
@tkhquang tkhquang deleted the style/format-comment-conventions branch June 11, 2026 06:12
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.

1 participant