Add log entry when versions are suppressed#329
Conversation
| return out, nil | ||
| } | ||
|
|
||
| // ListMinPackageAgeEvents fetches GET /v1/min-package-age-events?limit=N. |
There was a problem hiding this comment.
ListMinPackageAgeEvents and GetMinPackageAgeEvent duplicate the request/response handling logic already used by ListTlsEvents/GetTlsEvent; consider extracting a shared helper to avoid repeating nearly identical code.
Details
✨ AI Reasoning
Two new API helper functions were added that follow the exact same control flow and error handling as existing ListTlsEvents/GetTlsEvent: they validate input (for get), perform a doRequest, check StatusCode, decode JSON into a slice/struct, sort (for list), and return. This is a repeated business operation (fetching paginated events) implemented twice with only the endpoint path and Go type differing. Consolidation into a shared helper (parameterized by path and target type) would avoid duplicating the same request/response logic and reduce maintenance burden when behaviour changes (timeouts, decoding, status handling). The duplication was introduced by this change; it appears in the same file and is substantial (entire function bodies are near-identical).
🔧 How do I fix it?
Delete extra code. Extract repeated code sequences into reusable functions or methods. Use loops or data structures to eliminate repetitive patterns.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
| return nil | ||
| } | ||
|
|
||
| func (e *MinPackageAgeEvent) Validate() error { |
There was a problem hiding this comment.
MinPackageAgeEvent.Validate duplicates existing Validate logic (repeated required-field checks). Consider consolidating common validation to avoid duplicated business logic.
Details
✨ AI Reasoning
A new event type and its Validate method were added that duplicate the same field-presence validation pattern already present for other event types in this file. This repeats non-trivial business logic (required-field checks) in the same source, increasing maintenance surface: future changes to validation rules will need to be applied in multiple places.
🔧 How do I fix it?
Delete extra code. Extract repeated code sequences into reusable functions or methods. Use loops or data structures to eliminate repetitive patterns.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
| w.WriteHeader(http.StatusOK) | ||
| } | ||
|
|
||
| func (s *Server) handleMinPackageAge(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
handleMinPackageAge duplicates the token-validate/decode/validate/callback pattern in other handlers; extract common request-handling steps into a shared helper to avoid repeating the same logic.
Details
✨ AI Reasoning
A new HTTP handler was added that performs the same sequence of steps as several existing handlers: validate token, decode JSON into a typed event, call Validate(), acquire lock to fetch a callback field, invoke the callback if present, and return HTTP 200. This repeats substantial, non-trivial logic already implemented in other handler functions in the same module, increasing maintenance burden because bug fixes or behavioral changes would need to be applied in multiple places. Consolidating the shared flow into a helper or common handler would reduce duplication and the risk of inconsistent behavior.
🔧 How do I fix it?
Delete extra code. Extract repeated code sequences into reusable functions or methods. Use loops or data structures to eliminate repetitive patterns.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
Summary by Aikido
🚀 New Features
⚡ Enhancements
More info