From a212d1c5f0a73b514db4e858b17cfc03d2ed39a2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 13:16:32 +0100 Subject: [PATCH] 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 --- pkg/ueps/packet.go | 2 +- pkg/ueps/packet_test.go | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/ueps/packet.go b/pkg/ueps/packet.go index c53d554..86f9c72 100644 --- a/pkg/ueps/packet.go +++ b/pkg/ueps/packet.go @@ -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) diff --git a/pkg/ueps/packet_test.go b/pkg/ueps/packet_test.go index 0e24446..4be8669 100644 --- a/pkg/ueps/packet_test.go +++ b/pkg/ueps/packet_test.go @@ -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()) } }