You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is pure redundancy - if the value can't be MaxUint64 (validated at line 211), checking again at line 231 adds zero value.
167
+
132
168
### 1. Security
133
169
-**HTML/Template Injection**: Always use `html.EscapeString()` for any data interpolated into HTML, even if currently from trusted sources
134
170
-**Input Validation**: Validate all user inputs at boundaries (flags, API inputs)
@@ -154,28 +190,32 @@ The tool supports configuration via:
154
190
-**Retry Logic**: Failed operations should retry (with backoff) before failing
155
191
-**Idempotency**: Same input parameters should produce identical output every time
156
192
-**Validation**: Verify expected vs actual data counts; fail loudly if mismatched
157
-
-**Question to ask**: "If I run this twice with the same parameters, will I get identical results? What makes this non-deterministic?"
193
+
-**Use Correct Data Source**: For blockchain data, prefer receipt fields over transaction fields (e.g., `effectiveGasPrice` from receipt works for both legacy and EIP-1559 txs, while `gasPrice` from transaction is missing in EIP-1559)
194
+
-**Question to ask**: "If I run this twice with the same parameters, will I get identical results? What makes this non-deterministic? Am I reading from the authoritative data source?"
158
195
159
-
### 5. Error Handling
196
+
### 5. Error Handling & Logging
160
197
-**Error Wrapping**: Use `fmt.Errorf("context: %w", err)` to wrap errors with context
161
198
-**Single-line Messages**: Put context before `%w` in single line: `fmt.Errorf("failed after %d attempts: %w", n, err)`
162
199
-**Failure Modes**: Consider and handle all failure paths explicitly
163
200
-**Logging Levels**: Use appropriate levels (Error for failures, Warn for retries, Info for progress)
164
-
-**Question to ask**: "What can fail? How is each failure mode handled? Are errors properly wrapped?"
201
+
-**Progress Accuracy**: Progress counters must reflect ALL completed work (successes + final failures), not just successes, or progress will appear stuck during retries
202
+
-**Question to ask**: "What can fail? How is each failure mode handled? Are errors properly wrapped? Is progress logging accurate during retries/failures?"
165
203
166
204
### 6. Concurrency Patterns
167
205
-**Channel Closing**: Close channels in the correct goroutine (usually the sender); use atomic counters to coordinate
206
+
-**Channel Draining**: When using select with multiple channels and one closes, drain remaining channels to avoid missing messages
168
207
-**Worker Pools**: Use `sync.WaitGroup` to wait for workers; protect shared state with mutexes or channels
169
208
-**Race Conditions**: Run with `-race` flag during testing
170
209
-**Goroutine Leaks**: Ensure every goroutine can exit on context cancellation
171
-
-**Question to ask**: "Who closes each channel? Can any goroutine block forever? Does this have race conditions?"
210
+
-**Question to ask**: "Who closes each channel? Can any goroutine block forever? Does this have race conditions? Are all channel messages guaranteed to be read?"
172
211
173
212
### 7. Testing & Validation
174
213
-**Test Coverage**: Write tests for edge cases, not just happy paths
175
214
-**Error Injection**: Test retry logic, failure modes, and error paths
176
215
-**Resource Limits**: Test with large inputs to verify scalability
177
216
-**Cancellation**: Test that context cancellation stops operations immediately
178
-
-**Question to ask**: "What edge cases exist? How do I test failure modes?"
217
+
-**Documentation Consistency**: Ensure documentation accurately describes implementation behavior (e.g., "blocks are skipped" vs "command fails on errors")
218
+
-**Question to ask**: "What edge cases exist? How do I test failure modes? Does the documentation match what the code actually does?"
0 commit comments