Loading...
Loading...
Chinese Code Review Communication Reference - Script Templates, Priority Labeling (Must Fix/Suggested Change/For Reference Only), Countermeasures for Common Anti-patterns in Domestic Teams. Only invoke when the user explicitly uses /chinese-code-review, do not trigger automatically based on context.
npx skill4agent add 21307369/superpowers-zh chinese-code-review| Avoid (Imperative) | Recommend (Suggestive) |
|---|---|
| You must change this to X | It is recommended to consider using X because Y |
| This is written wrong | There might be an issue here. Have you considered scenario Z? |
| Don't use this method | This method may have performance issues in scenario A. You can look at solution B |
| This code doesn't work | Did I understand this logic correctly? What happens if the input is empty? |
# Good approach
What was the consideration for using sync to read files here? If concurrency increases, it might block the event loop.
# Bad approach
You shouldn't use sync to read files here.[Must Fix] SQL Injection Risk
Line 42: User input is directly concatenated into the SQL statement.
Reason: Attackers can inject `'; DROP TABLE users; --` via the name parameter.
Suggestion: Use parameterized queries:
db.query('SELECT * FROM users WHERE name = $1', [name])
Reference: https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html/**
* Calculate member level discount for users
*
* Business Rules:
* - Regular members: 5% off
* - Silver members: 10% off
* - Gold members: 15% off
* - Diamond members: 20% off
*
* @param level - Member level (MemberLevel enum)
* @param amount - Original amount (unit: cents)
* @returns Discounted amount (unit: cents)
*/
function calculateDiscount(level: MemberLevel, amount: number): number {
// ...
}// Good: Add space between Chinese and English
// Use Redis cache to reduce MySQL query pressure
// Bad: No space between Chinese and English
// 使用Redis缓存来减少MySQL的查询压力
// Good: Keep technical terms in English
// Use debounce to prevent frequent API requests
// Bad: Force translation of technical terms
// 这里用防抖动处理,避免频繁触发应用程序接口请求<type>(<scope>): <brief description>
<detailed explanation (optional)>
<relevant information (optional)>| Type | Meaning | Example |
|---|---|---|
| feat | New feature | feat(user): Add mobile phone login function |
| fix | Fix bug | fix(payment): Fix repeated processing of WeChat payment callbacks |
| docs | Document changes | docs: Update API documentation |
| style | Code format | style: Unify indentation to 2 spaces |
| refactor | Refactoring | refactor(order): Split order service and extract common logic |
| perf | Performance optimization | perf(list): Virtual scroll optimization for long list rendering performance |
| test | Testing | test(auth): Add unit tests for login module |
| chore | Build/tools | chore: Upgrade Node.js to v20 |
fix(payment): Fix Alipay asynchronous callback signature verification failure
Reason: After upgrading the SDK, the signature algorithm changed from RSA to RSA2, but callback verification still used the old algorithm.
Solution: Support both RSA and RSA2 signature verification in callback processing.
Closes #1234fix(payment): fix Alipay async callback signature verification failure
The SDK upgrade changed the signature algorithm from RSA to RSA2,
but the callback handler still used the old algorithm.
Closes #1234# Bad: Overly polite
I don't know if I understand correctly, but there might be a tiny concurrency issue here, though maybe I'm wrong...
# Good: Gentle but clear
[Must Fix] Concurrency Safety Issue
This map is being read and written simultaneously in multiple goroutines, which will trigger a panic.
It is recommended to add sync.RWMutex, or switch to sync.Map.
Reproduction method: Run tests with -race flag to see it.# Question-based (suitable for feedback to senior colleagues)
I'd like to ask, what was the consideration for choosing recursion instead of iteration here?
I'm thinking if the recursion depth exceeds 1000 layers, will there be a stack overflow risk?
# Learning-based
Learned a new writing style! But I have a small question — the type assertion here isn't checked at runtime.
If the upstream data structure changes, this will pass silently. Have you considered adding runtime validation?LGTM
Reviewed the following aspects:
- Concurrency safety: Lock granularity is reasonable
- Error handling: All external calls have error handling
- Backward compatibility: New fields all have default values, no impact on old versions
A small suggestion [For Reference Only]: The variable name `d` on line 78 can be changed to `duration` for better readability.Summary: The overall implementation idea is clear, and the idempotent processing of payment callbacks is well done.
Main Issues:
1. [Must Fix] Concurrent map write issues (2 places)
2. [Suggested Change] Missing null value validations (3 places)
3. [For Reference Only] Several variable names can be more semantic
Suggestion: Fix the concurrency issues first, and the validation part can be fixed in this iteration or split into the next one.