From 7f02b47445ebb4b6617e63bc8e94cfbfc09e6ee9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 13:59:57 +0100 Subject: [PATCH] =?UTF-8?q?ax(ueps):=20rename=20tagLengthByte=20to=20tagLe?= =?UTF-8?q?ngth=20=E2=80=94=20type=20suffix=20violates=20AX=20Principle=20?= =?UTF-8?q?1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Variable name tagLengthByte encoded its type (byte) rather than its role (the length field of a TLV record). AX Principle 1: names must be semantic, not type-annotated. tagLength is unambiguous without the redundant Byte suffix. Co-Authored-By: Charon --- pkg/ueps/reader.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/ueps/reader.go b/pkg/ueps/reader.go index c0d4e33..581978d 100644 --- a/pkg/ueps/reader.go +++ b/pkg/ueps/reader.go @@ -49,12 +49,12 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er break } - tagLengthByte, err := reader.ReadByte() + tagLength, err := reader.ReadByte() if err != nil { return nil, err } - tagValue := make([]byte, int(tagLengthByte)) + tagValue := make([]byte, int(tagLength)) if _, err := io.ReadFull(reader, tagValue); err != nil { return nil, err } @@ -63,33 +63,33 @@ func ReadAndVerify(reader *bufio.Reader, sharedSecret []byte) (*ParsedPacket, er case TagVersion: header.Version = tagValue[0] hmacInputBuffer.WriteByte(tagType) - hmacInputBuffer.WriteByte(tagLengthByte) + hmacInputBuffer.WriteByte(tagLength) hmacInputBuffer.Write(tagValue) case TagCurrentLayer: header.CurrentLayer = tagValue[0] hmacInputBuffer.WriteByte(tagType) - hmacInputBuffer.WriteByte(tagLengthByte) + hmacInputBuffer.WriteByte(tagLength) hmacInputBuffer.Write(tagValue) case TagTargetLayer: header.TargetLayer = tagValue[0] hmacInputBuffer.WriteByte(tagType) - hmacInputBuffer.WriteByte(tagLengthByte) + hmacInputBuffer.WriteByte(tagLength) hmacInputBuffer.Write(tagValue) case TagIntent: header.IntentID = tagValue[0] hmacInputBuffer.WriteByte(tagType) - hmacInputBuffer.WriteByte(tagLengthByte) + hmacInputBuffer.WriteByte(tagLength) hmacInputBuffer.Write(tagValue) case TagThreatScore: header.ThreatScore = binary.BigEndian.Uint16(tagValue) hmacInputBuffer.WriteByte(tagType) - hmacInputBuffer.WriteByte(tagLengthByte) + hmacInputBuffer.WriteByte(tagLength) hmacInputBuffer.Write(tagValue) case TagHMAC: hmacSignature = tagValue default: hmacInputBuffer.WriteByte(tagType) - hmacInputBuffer.WriteByte(tagLengthByte) + hmacInputBuffer.WriteByte(tagLength) hmacInputBuffer.Write(tagValue) } }