# πŸ” PR Review Guide for Maintainers **Language:** [English](PR_REVIEW_GUIDE.md) | [δΈ­ζ–‡](PR_REVIEW_GUIDE.zh-CN.md) This guide is for NOFX maintainers reviewing pull requests. --- ## πŸ“‹ Review Checklist ### 1. Initial Triage (Within 24 hours) - [ ] **Check PR alignment with roadmap** - Does it fit into our current priorities? - Is it in the [roadmap](../roadmap/README.md)? - If not, should we accept it anyway? - [ ] **Verify PR completeness** - All sections of PR template filled? - Clear description of changes? - Related issues linked? - Screenshots/demo for UI changes? - [ ] **Apply appropriate labels** - Priority: critical/high/medium/low - Type: bug/feature/enhancement/docs - Area: frontend/backend/exchange/ai/security - Status: needs review/needs changes - [ ] **Assign reviewers** - Assign based on area of expertise - At least 1 maintainer review required ### 2. Code Review #### A. Functionality Review ```markdown βœ… **Questions to Ask:** - Does it solve the stated problem? - Are edge cases handled? - Will this break existing functionality? - Is the approach correct for our architecture? - Are there better alternatives? ``` **Testing:** - [ ] All CI checks passed? - [ ] Manual testing performed by contributor? - [ ] Test coverage adequate? - [ ] Tests are meaningful (not just for coverage)? #### B. Code Quality Review **Go Backend Code:** ```go // ❌ Bad - Reject func GetData(a, b string) interface{} { d := doSomething(a, b) return d } // βœ… Good - Approve func GetAccountBalance(apiKey, secretKey string) (*Balance, error) { if apiKey == "" || secretKey == "" { return nil, fmt.Errorf("API credentials required") } balance, err := client.FetchBalance(apiKey, secretKey) if err != nil { return nil, fmt.Errorf("failed to fetch balance: %w", err) } return balance, nil } ``` **Check for:** - [ ] Meaningful variable/function names - [ ] Proper error handling (no ignored errors) - [ ] Comments for complex logic - [ ] No hardcoded values (use constants/config) - [ ] Follows Go idioms and conventions - [ ] No unnecessary complexity **TypeScript/React Frontend Code:** ```typescript // ❌ Bad - Reject const getData = (data: any) => { return data.map(d =>
{d.name}
) } // βœ… Good - Approve interface Trader { id: string; name: string; status: 'running' | 'stopped'; } const TraderList: React.FC<{ traders: Trader[] }> = ({ traders }) => { return (
{traders.map(trader => ( ))}
); }; ``` **Check for:** - [ ] Type safety (no `any` unless absolutely necessary) - [ ] Proper React patterns (hooks, functional components) - [ ] Component reusability - [ ] Accessibility (a11y) considerations - [ ] Performance optimizations (memoization where needed) #### C. Security Review **Critical Checks:** ```go // 🚨 REJECT - Security Issue func Login(username, password string) { query := "SELECT * FROM users WHERE username='" + username + "'" // SQL Injection! db.Query(query) } // βœ… APPROVE - Secure func Login(username, password string) error { query := "SELECT * FROM users WHERE username = ?" row := db.QueryRow(query, username) // Parameterized query // ... proper password verification with bcrypt } ``` - [ ] No SQL injection vulnerabilities - [ ] No XSS vulnerabilities in frontend - [ ] API keys/secrets not hardcoded - [ ] User inputs properly validated - [ ] Authentication/authorization properly handled - [ ] No sensitive data in logs - [ ] Dependencies have no known vulnerabilities #### D. Performance Review - [ ] No obvious performance issues - [ ] Database queries optimized (indexes, no N+1 queries) - [ ] No unnecessary API calls - [ ] Proper caching where applicable - [ ] No memory leaks ### 3. Documentation Review - [ ] Code comments for complex logic - [ ] README updated if needed - [ ] API documentation updated (if API changes) - [ ] Migration guide for breaking changes - [ ] Changelog entry (for significant changes) ### 4. Testing Review - [ ] Unit tests for new functions - [ ] Integration tests for new features - [ ] Tests actually test the functionality (not just coverage) - [ ] Test names are descriptive - [ ] Mock data is realistic --- ## 🏷️ Label Management ### Priority Assignment Use these criteria to assign priority: **Critical:** - Security vulnerabilities - Production-breaking bugs - Data loss issues **High:** - Major bugs affecting many users - High-priority roadmap features - Performance issues **Medium:** - Regular bug fixes - Standard feature requests - Refactoring **Low:** - Minor improvements - Code style changes - Non-urgent documentation ### Status Workflow ``` needs review β†’ in review β†’ needs changes β†’ needs review β†’ approved β†’ merged ↓ on hold ``` **Status Labels:** - `status: needs review` - Ready for initial review - `status: in progress` - Being actively reviewed - `status: needs changes` - Reviewer requested changes - `status: on hold` - Waiting for discussion/decision - `status: blocked` - Blocked by another PR/issue --- ## πŸ’¬ Providing Feedback ### Writing Good Review Comments **❌ Bad Comments:** ``` This is wrong. Change this. Why did you do this? ``` **βœ… Good Comments:** ``` This approach might cause issues with concurrent requests. Consider using a mutex or atomic operations here. Suggestion: Extract this logic into a separate function for better testability: ```go func validateTraderConfig(config *TraderConfig) error { // validation logic } ``` Question: Have you considered using the existing `ExchangeClient` interface instead of creating a new one? This would maintain consistency with the rest of the codebase. ``` ### Comment Types **πŸ”΄ Blocking (must be addressed):** ```markdown **BLOCKING:** This introduces a SQL injection vulnerability. Please use parameterized queries instead. ``` **🟑 Non-blocking (suggestions):** ```markdown **Suggestion:** Consider using `strings.Builder` here for better performance when concatenating many strings. ``` **🟒 Praise (encourage good practices):** ```markdown **Nice!** Great use of context for timeout handling. This is exactly what we want to see. ``` ### Questions vs Directives **❌ Directive (can feel demanding):** ``` Change this to use the factory pattern. Add tests for this function. ``` **βœ… Question (more collaborative):** ``` Would the factory pattern be a better fit here? It might make testing easier. Could you add a test case for the error path? I want to make sure we handle failures gracefully. ``` --- ## ⏱️ Response Time Guidelines | PR Type | Initial Review | Follow-up | Merge Decision | |---------|---------------|-----------|----------------| | **Critical Bug** | 4 hours | 2 hours | Same day | | **Bounty PR** | 24 hours | 12 hours | 2-3 days | | **Feature** | 2-3 days | 1-2 days | 3-5 days | | **Documentation** | 2-3 days | 1-2 days | 3-5 days | | **Large PR** | 3-5 days | 2-3 days | 5-7 days | --- ## βœ… Approval Criteria A PR should be approved when: 1. **Functionality** - βœ… Solves the stated problem - βœ… No regression in existing features - βœ… Edge cases handled 2. **Quality** - βœ… Follows code standards - βœ… Well-structured and readable - βœ… Adequate test coverage 3. **Security** - βœ… No security vulnerabilities - βœ… Inputs validated - βœ… Secrets properly managed 4. **Documentation** - βœ… Code commented where needed - βœ… Docs updated if applicable 5. **Process** - βœ… All CI checks pass - βœ… All review comments addressed - βœ… Rebased on latest dev branch --- ## 🚫 Rejection Criteria Reject a PR if: **Immediate Rejection:** - πŸ”΄ Introduces security vulnerabilities - πŸ”΄ Contains malicious code - πŸ”΄ Violates Code of Conduct - πŸ”΄ Contains plagiarized code - πŸ”΄ Hardcoded API keys or secrets **Request Changes:** - 🟑 Poor code quality (after feedback ignored) - 🟑 No tests for new features - 🟑 Breaking changes without migration path - 🟑 Doesn't align with roadmap (without prior discussion) - 🟑 Incomplete (missing critical parts) **Close with Explanation:** - 🟠 Duplicate functionality - 🟠 Out of scope for project - 🟠 Better alternative already exists - 🟠 Contributor unresponsive for >2 weeks --- ## 🎯 Special Case Reviews ### Bounty PRs Extra care needed: - [ ] All acceptance criteria met? - [ ] Demo video/screenshots provided? - [ ] Working as specified in bounty issue? - [ ] Payment info discussed privately? - [ ] Priority review (24h turnaround) ### Breaking Changes - [ ] Migration guide provided? - [ ] Deprecation warnings added? - [ ] Version bump planned? - [ ] Backward compatibility considered? - [ ] RFC (Request for Comments) created for major changes? ### Security PRs - [ ] Verified by security-focused reviewer? - [ ] No public disclosure of vulnerability? - [ ] Coordinated disclosure if needed? - [ ] Security advisory prepared? - [ ] Patch release planned? --- ## πŸ”„ Merge Guidelines ### When to Merge Merge when: - βœ… At least 1 approval from maintainer - βœ… All CI checks passing - βœ… All conversations resolved - βœ… No requested changes pending - βœ… Rebased on latest target branch ### Merge Strategy **Squash Merge** (default for most PRs): - Small bug fixes - Single-feature PRs - Documentation updates - Keeps git history clean **Merge Commit** (for complex PRs): - Multi-commit features with logical commits - Preserve commit history - Large refactoring with atomic commits **Rebase and Merge** (rarely): - When linear history is important - Commits are already well-structured ### Merge Commit Message Format: ``` (): (#123) Brief description of changes. - Key change 1 - Key change 2 Co-authored-by: Contributor Name ``` --- ## πŸ“Š Review Metrics to Track Monitor these metrics monthly: - Average time to first review - Average time to merge - PR acceptance rate - Number of PRs by type (bug/feature/docs) - Number of PRs by area (frontend/backend/exchange) - Contributor retention rate --- ## πŸ™‹ Questions? If unsure about a PR: 1. **Ask other maintainers** in private channel 2. **Request more context** from contributor 3. **Mark as "on hold"** and add to next maintainer sync 4. **When in doubt, be conservative** - better to ask than approve something risky --- ## πŸ”— Related Resources - [Contributing Guide](../../CONTRIBUTING.md) - [Code of Conduct](../../CODE_OF_CONDUCT.md) - [Security Policy](../../SECURITY.md) - [Project Roadmap](../roadmap/README.md) --- **Remember:** Reviews should be **respectful**, **constructive**, and **educational**. We're building a community, not just code. πŸš€