Skip to content

Commit e3c0f64

Browse files
ykmr1224asifabashar
authored andcommitted
Improve coderabbit config (opensearch-project#5048)
* Improve coderabbit config Signed-off-by: Tomoyuki Morita <moritato@amazon.com> * Address comment Signed-off-by: Tomoyuki Morita <moritato@amazon.com> * update REVIEW_GUIDELINES.md Signed-off-by: Tomoyuki Morita <moritato@amazon.com> --------- Signed-off-by: Tomoyuki Morita <moritato@amazon.com>
1 parent d8dc320 commit e3c0f64

2 files changed

Lines changed: 70 additions & 48 deletions

File tree

.coderabbit.yaml

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ reviews:
1414
poem: false # Keep reviews professional and concise
1515
review_status: true
1616
collapse_walkthrough: true
17-
17+
path_filters:
18+
- '**/*'
19+
- '!**/test/**/gen/**'
20+
- '!**/.git/**'
21+
- '!**/target/**'
1822
auto_review:
1923
enabled: true
2024
auto_incremental_review: true
@@ -23,13 +27,6 @@ reviews:
2327
- "WIP"
2428
- "DO NOT MERGE"
2529
- "DRAFT"
26-
27-
# General review instructions (applied to all reviews)
28-
instructions:
29-
# Architectural Decision Prompts
30-
- "For new features: Check if similar functionality exists that could be enhanced instead"
31-
- "Question whether new code is needed vs reusing/extending existing code"
32-
- "Identify opportunities for code reuse across the codebase"
3330

3431
# Path-specific review instructions
3532
path_instructions:
@@ -47,21 +44,10 @@ reviews:
4744
- Validate command follows PPL naming and structure patterns
4845
- Check if command should be alias vs separate implementation
4946
50-
# Java Files - Code Organization and Quality
47+
# Java Files - Apply general guidelines from REVIEW_GUIDELINES.md
5148
- path: "**/*.java"
5249
instructions: |
53-
- Flag methods >50 lines as potentially too complex - suggest refactoring
54-
- Flag classes >500 lines as needing organization review
55-
- Check for dead code, unused imports, and unused variables
56-
- Identify code reuse opportunities across similar implementations
57-
- Assess holistic maintainability - is code easy to understand and modify?
58-
- Flag code that appears AI-generated without sufficient human review
59-
- Verify Java naming conventions (PascalCase for classes, camelCase for methods/variables)
60-
- Check for proper JavaDoc on public classes and methods
61-
- Flag redundant comments that restate obvious code
62-
- Ensure proper error handling with specific exception types
63-
- Check for Optional<T> usage instead of null returns
64-
- Validate proper use of try-with-resources for resource management
50+
Apply all Java Standards from REVIEW_GUIDELINES.md
6551
6652
# Core Java - Project-Specific Patterns
6753
- path: "core/src/main/java/**/*.java"
@@ -85,20 +71,10 @@ reviews:
8571
- Follow visitor pattern for AST traversal
8672
- Ensure proper toString() implementation for debugging
8773
88-
# Test Files - Enhanced Coverage Validation
74+
# Test Files - Apply testing guidelines from REVIEW_GUIDELINES.md
8975
- path: "**/test/**/*.java"
9076
instructions: |
91-
- Verify NULL input tests for all new functions
92-
- Check boundary condition tests (min/max values, empty inputs)
93-
- Validate error condition tests (invalid inputs, exceptions)
94-
- Ensure multi-document tests for per-document operations
95-
- Flag smoke tests without meaningful assertions
96-
- Check test naming follows pattern: test<Functionality><Condition>
97-
- Verify test data is realistic and covers edge cases
98-
- Verify test coverage for new business logic
99-
- Ensure tests are independent and don't rely on execution order
100-
- Validate meaningful test data that reflects real-world scenarios
101-
- Check for proper cleanup of test resources
77+
Apply all Testing Requirements from REVIEW_GUIDELINES.md
10278
10379
# Integration Tests
10480
- path: "integ-test/**/*IT.java"
@@ -108,17 +84,19 @@ reviews:
10884
- Check test assertions are meaningful and specific
10985
- Validate tests clean up resources after execution
11086
- Ensure tests are independent and can run in any order
111-
- Flag tests that reference non-existent indices (e.g., EMP)
11287
- Verify integration tests are in correct module (integ-test/)
11388
- Check tests can be run with ./gradlew :integ-test:integTest
11489
- Ensure proper test data setup and teardown
11590
- Validate end-to-end scenario coverage
91+
- Do NOT flag inline test data as problematic if it improves test clarity
92+
- Do NOT suggest removing helper methods that are used multiple times in the same test class
11693
11794
- path: "integ-test/src/test/resources/**/*"
11895
instructions: |
11996
- Verify test data is realistic and representative
12097
- Check data format matches expected schema
12198
- Ensure test data covers edge cases and boundary conditions
99+
- Do NOT flag NDJSON format as invalid JSON
122100
123101
# PPL-specific
124102
- path: "**/ppl/**/*.java"
@@ -147,14 +125,14 @@ reviews:
147125
- Check for code organization and logical grouping
148126
- Validate all RelNode types are handled
149127
150-
# Documentation
151-
- path: "docs/**/*.rst"
128+
- path: "docs/**/*.md"
152129
instructions: |
153130
- Verify examples use valid test data and indices
154131
- Check documentation follows existing patterns and structure
155132
- Validate syntax examples are complete and correct
156133
- Ensure code examples are tested and working
157134
- Check for consistent formatting and style
135+
- Do NOT flag missing language identifiers in code blocks as critical issues
158136
159137
chat:
160138
auto_reply: false # require explicit tagging

.rules/REVIEW_GUIDELINES.md

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Code Review Guidelines for OpenSearch SQL
22

3-
This document provides guidelines for code reviews in the OpenSearch SQL project. These guidelines are used by CodeRabbit AI for automated code reviews and serve as a reference for human reviewers.
3+
This document provides general code review principles and standards for the OpenSearch SQL project. These guidelines apply across all file types and are used by CodeRabbit AI for automated code reviews.
44

55
## Core Review Principles
66

@@ -9,19 +9,40 @@ This document provides guidelines for code reviews in the OpenSearch SQL project
99
- **Self-Documenting Code**: Code should be clear through naming and structure, not comments
1010
- **No Redundant Comments**: Avoid comments that merely restate what the code does
1111
- **Concise Implementation**: Keep code, docs, and notes short and focused on essentials
12+
- **Code Reuse**: Identify opportunities across similar implementations
13+
- **Maintainability**: Assess if code is easy to understand and modify
1214

1315
### Java Standards
1416
- **Naming Conventions**:
1517
- Classes: `PascalCase` (e.g., `QueryExecutor`)
1618
- Methods/Variables: `camelCase` (e.g., `executeQuery`)
1719
- Constants: `UPPER_SNAKE_CASE` (e.g., `MAX_RETRY_COUNT`)
18-
- **Method Size**: Keep methods under 20 lines with single responsibility
20+
- **Method Size**:
21+
- Target: Under 20 lines with single responsibility
22+
- Suggest refactoring: Methods >100 lines
23+
- **Class Size**: Flag classes >500 lines for organization review
1924
- **JavaDoc Required**: All public classes and methods must have proper JavaDoc
25+
- NOT required on test methods, test helpers, override methods, or private methods
2026
- **Error Handling**: Use specific exception types with meaningful messages
2127
- **Null Safety**: Prefer `Optional<T>` for nullable returns
28+
- **Resource Management**: Use try-with-resources for proper cleanup
29+
- **Dead Code**: Check for unused imports, variables, and methods
2230

2331
### Testing Requirements
24-
- **Test Coverage**: All new business logic requires unit tests
32+
- **Test Coverage**: All new business logic requires unit tests in the same commit
33+
- **Required Test Cases**:
34+
- NULL input tests for all new functions
35+
- Boundary condition tests (min/max values, empty inputs)
36+
- Error condition tests (invalid inputs, exceptions)
37+
- Multi-document tests for per-document operations
38+
- **Test Naming**: Follow pattern `test<Functionality><Condition>`
39+
- **Test Independence**: Tests must not rely on execution order
40+
- **Test Data**:
41+
- Use realistic data that reflects real-world scenarios
42+
- Inline test data is acceptable when it improves readability
43+
- Don't require loading from files if inline is clearer
44+
- **Test Assertions**: Flag smoke tests without meaningful assertions only if they provide no value
45+
- **Resource Cleanup**: Ensure proper cleanup of test resources
2546
- **Integration Tests**: End-to-end scenarios need integration tests in `integ-test/` module
2647
- **Test Execution**: Verify changes with `./gradlew :integ-test:integTest`
2748
- **No Failing Tests**: All tests must pass before merge; fix or ask for guidance if blocked
@@ -37,7 +58,6 @@ This document provides guidelines for code reviews in the OpenSearch SQL project
3758
- **String Handling**: Use `StringBuilder` for concatenation in loops
3859
- **Input Validation**: Validate all user inputs, especially queries
3960
- **Logging Safety**: Sanitize data before logging to prevent injection
40-
- **Resource Management**: Use try-with-resources for proper cleanup
4161

4262
## Review Focus Areas
4363

@@ -51,7 +71,7 @@ This document provides guidelines for code reviews in the OpenSearch SQL project
5171

5272
### What to Flag
5373
- Redundant or obvious comments
54-
- Methods longer than 20 lines
74+
- Methods longer than target size (see Java Standards)
5575
- Missing JavaDoc on public APIs
5676
- Generic exception handling
5777
- Unused imports or dead code
@@ -66,23 +86,47 @@ This document provides guidelines for code reviews in the OpenSearch SQL project
6686
- Efficient algorithms and data structures
6787
- Security-conscious coding practices
6888

69-
## Project-Specific Guidelines
89+
## Project Context
7090

71-
### OpenSearch SQL Context
91+
### OpenSearch SQL
7292
- **JDK 21**: Required for development
7393
- **Java 11 Compatibility**: Maintain when possible for OpenSearch 2.x
74-
- **Module Structure**: Respect existing module boundaries
75-
- **Integration Tests**: Use `./gradlew :integ-test:integTest` for testing
94+
- **Module Structure**: Respect existing module boundaries (core, ppl, sql, opensearch, integ-test)
7695
- **Test Naming**: `*IT.java` for integration tests, `*Test.java` for unit tests
7796

78-
### PPL Parser Changes
97+
### Grammar and Parser Development
7998
- Test new grammar rules with positive and negative cases
8099
- Verify AST generation for new syntax
81100
- Include edge cases and boundary conditions
82101
- Update corresponding AST builder classes
102+
- Check for code reuse opportunities vs creating new rules
83103

84104
### Calcite Integration
85-
- If the PR is for PPL command, refer docs/dev/ppl-commands.md and verify the PR satisfy the checklist.
86-
- Follow existing patterns in `CalciteRelNodeVisitor` and `CalciteRexNodeVisitor`
105+
- Follow existing patterns in visitor implementations
87106
- Test SQL generation and optimization paths
88107
- Document Calcite-specific workarounds
108+
- Ensure version compatibility
109+
110+
## Review Tone and Focus
111+
112+
### Review Priorities
113+
- **Correctness** > Performance > Maintainability > Style
114+
- Focus on functional issues, not cosmetic ones
115+
- Explain WHY when suggesting improvements, not just WHAT
116+
- Avoid repeating the same suggestion multiple times
117+
118+
### What NOT to Flag
119+
- Minor refactorings unless code is clearly problematic (>100 lines, deeply nested, etc.)
120+
- Missing JavaDoc on test methods, test helpers, override methods, or private methods
121+
- Inline test data when it improves readability
122+
- NDJSON format as invalid JSON
123+
- Missing language identifiers in markdown code blocks (unless in documentation files)
124+
- Hard-coded test data when it's intentionally inline for clarity
125+
- Helper methods in tests unless they're truly unused
126+
- Extracting helper methods unless the method exceeds 100 lines
127+
128+
### Keep Reviews Concise
129+
- Be direct and actionable
130+
- Focus on significant issues that impact functionality or maintainability
131+
- Avoid nitpicking on style preferences
132+
- Prioritize issues that could cause bugs or maintenance problems

0 commit comments

Comments
 (0)