ax(ueps): rename single-letter sentinel test variables to descriptive names

Variables e, a, b violate AX Principle 1 (predictable names over short names).
Renamed to sentinel, sentinelFirst, sentinelSecond across test functions and
the usage-example comment in packet.go.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 13:16:32 +01:00
parent 895dec281b
commit a212d1c5f0
No known key found for this signature in database
GPG key ID: AF404715446AEB41
2 changed files with 16 additions and 16 deletions

View file

@ -15,7 +15,7 @@ var errTLVValueTooLarge = sentinelError("TLV value too large for 1-byte length h
// var errNotFound = sentinelError("record not found"); if err == errNotFound { /* handle */ }
type sentinelError string
// var e sentinelError = "thing not found"; e.Error() == "thing not found"
// var sentinel sentinelError = "thing not found"; sentinel.Error() == "thing not found"
func (sentinelErrorValue sentinelError) Error() string { return string(sentinelErrorValue) }
// writeTLV(buffer, TagVersion, []byte{0x09}); writeTLV(buffer, TagHMAC, hmacSignature); buffer.WriteByte(TagPayload)

View file

@ -207,33 +207,33 @@ func TestPacket_writeTLV_Ugly(t *testing.T) {
}
}
// var e sentinelError = "record not found"; e.Error() == "record not found"
// var sentinel sentinelError = "record not found"; sentinel.Error() == "record not found"
func TestPacket_sentinelError_Good(t *testing.T) {
e := sentinelError("record not found")
sentinel := sentinelError("record not found")
if e.Error() != "record not found" {
t.Errorf("expected %q, got %q", "record not found", e.Error())
if sentinel.Error() != "record not found" {
t.Errorf("expected %q, got %q", "record not found", sentinel.Error())
}
}
// var e sentinelError = ""; e.Error() == "" (empty message is valid sentinel)
// var sentinel sentinelError = ""; sentinel.Error() == "" (empty message is valid sentinel)
func TestPacket_sentinelError_Bad(t *testing.T) {
e := sentinelError("")
sentinel := sentinelError("")
if e.Error() != "" {
t.Errorf("expected empty string, got %q", e.Error())
if sentinel.Error() != "" {
t.Errorf("expected empty string, got %q", sentinel.Error())
}
}
// var a, b sentinelError = "x", "x"; a == b (sentinel identity: same message = same error)
// var sentinelFirst, sentinelSecond sentinelError = "x", "x"; sentinelFirst == sentinelSecond (sentinel identity: same message = same error)
func TestPacket_sentinelError_Ugly(t *testing.T) {
a := sentinelError("integrity violation")
b := sentinelError("integrity violation")
sentinelFirst := sentinelError("integrity violation")
sentinelSecond := sentinelError("integrity violation")
if a != b {
t.Errorf("expected sentinel identity: %q == %q", a, b)
if sentinelFirst != sentinelSecond {
t.Errorf("expected sentinel identity: %q == %q", sentinelFirst, sentinelSecond)
}
if a.Error() != b.Error() {
t.Errorf("expected identical Error() output, got %q vs %q", a.Error(), b.Error())
if sentinelFirst.Error() != sentinelSecond.Error() {
t.Errorf("expected identical Error() output, got %q vs %q", sentinelFirst.Error(), sentinelSecond.Error())
}
}