Skip to content

Conversation

LinZhihao-723
Copy link
Member

@LinZhihao-723 LinZhihao-723 commented Sep 24, 2025

Description

This PR depends on #86.

This PR adds a new script to create symlinks for Rust lint configs.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Checked within this repo to ensure a symlink to rustfmt.toml lint config is properly created.

Summary by CodeRabbit

  • New Features

    • Introduced a reusable tool to symlink lint/format configuration files to the repository root with validation, informative messages, and safe error handling.
    • Added a lightweight wrapper to set up the Rust formatting configuration via the shared tool.
  • Refactor

    • Simplified the C++ lint/format setup by delegating to the shared symlinking tool, standardizing behaviour and reducing duplication.
  • Chores

    • Improved error handling and usage guidance across lint-configuration scripts.

@LinZhihao-723 LinZhihao-723 requested a review from a team as a code owner September 24, 2025 20:45
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Walkthrough

Introduces a reusable symlink utility script and updates language-specific wrappers to delegate to it. Adds a new Rust wrapper. The C++ wrapper now calls the shared script for .clang-format and .clang-tidy. The utility validates input, resolves paths, computes relative paths, and manages symlink creation at the repo root.

Changes

Cohort / File(s) Summary of Changes
Core symlink utility
exports/lint-configs/symlink-config.sh
New script to create repo-root symlinks for provided config paths; enforces single-arg usage, validates existence, resolves absolute/relative paths, computes repo-relative target, and creates or reports on symlink conflicts. Includes main entrypoint; uses set -e -u.
CPP wrapper update
exports/lint-configs/symlink-cpp-lint-configs.sh
Replaced inline symlink logic with two calls to symlink-config.sh for .clang-format and .clang-tidy; removed duplicated validation and path handling.
Rust wrapper added
exports/lint-configs/symlink-rust-lint-configs.sh
New wrapper that resolves its directory, enables strict mode, and invokes symlink-config.sh for .rustfmt.toml.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant CPP as symlink-cpp-lint-configs.sh
  participant RUST as symlink-rust-lint-configs.sh
  participant CORE as symlink-config.sh
  participant FS as Filesystem

  Dev->>CPP: Run script
  CPP->>CORE: symlink .clang-format
  CORE->>FS: Validate paths, create/update symlink at repo root
  FS-->>CORE: Result
  CORE-->>CPP: Status/message
  CPP->>CORE: symlink .clang-tidy
  CORE->>FS: Validate paths, create/update symlink at repo root
  FS-->>CORE: Result
  CORE-->>CPP: Status/message

  Dev->>RUST: Run script
  RUST->>CORE: symlink .rustfmt.toml
  CORE->>FS: Validate paths, create/update symlink at repo root
  FS-->>CORE: Result
  CORE-->>RUST: Status/message
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly summarises the primary change of adding the symlink-rust-lint-configs.sh script for Rust lint configuration symlinks in the lint-configs module, matching the content of the PR and following conventional commit style.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1202b9 and 0e56d91.

📒 Files selected for processing (3)
  • exports/lint-configs/symlink-config.sh (1 hunks)
  • exports/lint-configs/symlink-cpp-lint-configs.sh (1 hunks)
  • exports/lint-configs/symlink-rust-lint-configs.sh (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
exports/lint-configs/symlink-config.sh (1)
exports/lint-configs/symlink-cpp-lint-configs.sh (1)
  • main (11-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: unit-tests (ubuntu-24.04)
  • GitHub Check: unit-tests (ubuntu-22.04)
🔇 Additional comments (3)
exports/lint-configs/symlink-cpp-lint-configs.sh (1)

12-13: LGTM: delegation to shared utility simplifies maintenance.

Good move consolidating logic into symlink-config.sh.

exports/lint-configs/symlink-config.sh (1)

24-25: Fix portability and broken-symlink handling

Apply the diff to:

  • replace readlink -f with a realpath … 2>/dev/null fallback and abort on failure (macOS compatibility);
  • remove the extra slash in src_path;
  • refactor the symlink logic to handle broken links, missing files and mismatched targets.

Manually test on both macOS and Linux for:

  • fresh creation
  • already-correct symlink
  • broken symlink at destination
  • conflicting non-symlink file at destination
exports/lint-configs/symlink-rust-lint-configs.sh (1)

11-13: No change needed for symlink script
The file exports/lint-configs/.rustfmt.toml exists, so the script correctly references .rustfmt.toml.

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