ax(node): replace prose comments with usage examples in protocol.go
Some checks failed
Test / test (push) Waiting to run
Security Scan / security (push) Has been cancelled

ValidateResponse, ParseResponse, and GetProtocolErrorCode had comments
that restated the function signature in prose — violating AX Principle 2
which requires comments to show concrete call-site usage, not descriptions.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 10:28:54 +01:00
parent 5843720a49
commit 7a87f2e633
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -60,12 +60,13 @@ func (h *ResponseHandler) ParseResponse(resp *Message, expectedType MessageType,
// DefaultResponseHandler is the default response handler instance.
var DefaultResponseHandler = &ResponseHandler{}
// ValidateResponse is a convenience function using the default handler.
// if err := ValidateResponse(resp, MsgPong); err != nil { return 0, err }
func ValidateResponse(resp *Message, expectedType MessageType) error {
return DefaultResponseHandler.ValidateResponse(resp, expectedType)
}
// ParseResponse is a convenience function using the default handler.
// var stats StatsPayload
// if err := ParseResponse(resp, MsgStats, &stats); err != nil { return nil, err }
func ParseResponse(resp *Message, expectedType MessageType, target interface{}) error {
return DefaultResponseHandler.ParseResponse(resp, expectedType, target)
}
@ -76,7 +77,7 @@ func IsProtocolError(err error) bool {
return ok
}
// GetProtocolErrorCode returns the error code if err is a ProtocolError, otherwise returns 0.
// code := GetProtocolErrorCode(err) // 0 when err is not a ProtocolError
func GetProtocolErrorCode(err error) int {
if pe, ok := err.(*ProtocolError); ok {
return pe.Code