Code RoomValidation metrics skipped
MediumPrep Room Coding #2081

Validation metrics skipped

Code reviewCode quality & reviewMid–Senior~16 min

Review this Go validation that records each failed check for a metrics counter, then decides whether the request is valid.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 16 min
Mark a line and say what kind of problem it is.0 findings
1func validate(r Req) bool {
2 return recordIfBad(checkAuth(r)) ||
3 recordIfBad(checkRate(r)) ||
4 recordIfBad(checkSchema(r))
5}
6 
7// recordIfBad returns true when the check FAILED, and increments a per-check failure counter.
8func recordIfBad(failed bool) bool {
9 if failed { failureCounter.Inc() }
10 return failed
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.