Skip to content

Commit 4ade123

Browse files
authored
feat: Add custom CodeRabbit instructions for examples (hiero-ledger#1189)
Signed-off-by: Adityarya11 <[email protected]>
1 parent b97935d commit 4ade123

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

.coderabbit.yaml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,51 @@ reviews:
1818
in_progress_fortune: false # Do not stall time with a message (spammy)
1919
poem: false # Do not write a literal poem (spammy)
2020
enable_prompt_for_ai_agents: false # Disable prompts for AI agents (spammy)
21+
22+
# --- CUSTOM INSTRUCTIONS FOR EXAMPLES DIRECTORY ---
23+
path_instructions:
24+
- path: "examples/**/*"
25+
instructions: |
26+
You are acting as a senior maintainer reviewing SDK examples. Your goal is to ensure examples work verbatim for users who copy-paste them.
27+
28+
**Priority 1 - Correctness**:
29+
- Verify transaction lifecycle chain (construction -> freeze_with -> sign -> execute).
30+
- Ensure `freeze_with(client)` is called BEFORE signing.
31+
- Validate that methods referenced actually exist in the `hiero_sdk_python` codebase.
32+
- Ensure response validation checks `receipt.status` against `ResponseCode` enums (e.g., `ResponseCode.SUCCESS`).
33+
34+
**Priority 2 - Transaction Lifecycle**:
35+
- Check method chaining logic.
36+
- Verify correct signing order (especially for multi-sig).
37+
- Ensure explicit `.execute(client)` calls.
38+
- Verify response property extraction (e.g., using `.token_id`, `.account_id`, `.serial_numbers`).
39+
- Ensure error handling uses `ResponseCode(receipt.status).name` for clarity.
40+
41+
**Priority 3 - Naming & Clarity**:
42+
- Enforce role-based naming: `operator_id`/`_key`, `treasury_account_id`/`_key`, `receiver_id`/`_key`.
43+
- Use `_id` suffix for AccountId and `_key` suffix for PrivateKey variables.
44+
- Validate negative examples explicitly check for failure codes (e.g., `TOKEN_HAS_NO_PAUSE_KEY`).
45+
- Ensure logical top-to-bottom flow without ambiguity.
46+
47+
**Priority 4 - Consistency**:
48+
- Verify standard patterns: `def main()`, `if __name__ == "__main__":`, `load_dotenv()`.
49+
- **IMPORT RULES**:
50+
1. Accept both top-level imports (e.g., `from hiero_sdk_python import PrivateKey`) and fully qualified imports (e.g., `from hiero_sdk_python.crypto.private_key import PrivateKey`).
51+
2. STRICTLY validate that the import path actually exists in the project structure. Compare against other files in `/examples` or your knowledge of the SDK file tree.
52+
3. Flag hallucinations immediately (e.g., `hiero_sdk_python.keys` does not exist).
53+
- Check for `try-except` blocks with `sys.exit(1)` for critical failures.
54+
55+
**Priority 5 - User Experience**:
56+
- Ensure comments explain SDK usage patterns (for users, not contributors).
57+
- Avoid nitpicking functional code.
58+
- Suggest type hints or docstrings only if they significantly improve clarity.
59+
60+
**Philosophy**:
61+
- Examples are copied by users - prioritize explicitness over brevity.
62+
- Avoid suggestions that `ruff` or linters would catch.
63+
- Be concise, technical, and opinionated.
64+
- Flag out-of-scope improvements as potential new issues rather than blocking.
65+
2166
chat:
2267
art: false # Don't draw ASCII art (false)
23-
auto_reply: false # Don't allow bot to converse (spammy)
68+
auto_reply: false # Don't allow bot to converse (spammy)

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
5656
- Added GitHub workflow that makes sure newly added test files follow pytest test files naming conventions (#1054)
5757
- Added advanced issue template for contributors `.github/ISSUE_TEMPLATE/06_advanced_issue.yml`.
5858
- Add new tests to `tests/unit/topic_info_query_test.py` (#1124)
59+
- Added prompt for codeRabbit on how to review /examples ([#1180](https://github.com/hiero-ledger/hiero-sdk-python/issues/1180))
5960

6061
### Changed
6162
- Reduce office-hours reminder spam by posting only on each user's most recent open PR, grouping by author and sorting by creation time (#1121)

0 commit comments

Comments
 (0)