Skip to content

Commit b61d158

Browse files
committed
fix line sizes
1 parent c0cc9d4 commit b61d158

File tree

8 files changed

+23
-12
lines changed

8 files changed

+23
-12
lines changed

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ linters:
1010
- wrapcheck
1111
# planned to fix:
1212
- err113
13-
- lll
1413
- testpackage
1514

1615
enable:
@@ -44,6 +43,7 @@ linters:
4443
- inamedparam
4544
- intrange
4645
- ireturn
46+
- lll
4747
- nilerr # Finds redundant nil checks on errors
4848
- nilnil # Checks that there is no simultaneous return of nil error and nil value
4949
- nlreturn
@@ -83,3 +83,5 @@ linters-settings:
8383
goconst:
8484
min-len: 3
8585

86+
lll:
87+
line-length: 80

internal/connect/crypt/blowfish.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ func DefaultAuthKey() *BlowfishCipher {
5151
// decryption for results to match.
5252
func flip4BytesEndianInplace(data []byte) {
5353
for i := 0; i < len(data); i += 4 {
54-
data[i], data[i+1], data[i+2], data[i+3] = data[i+3], data[i+2], data[i+1], data[i]
54+
data[i], data[i+3] = data[i+3], data[i]
55+
data[i+1], data[i+2] = data[i+2], data[i+1]
5556
}
5657
}
5758

@@ -63,7 +64,8 @@ func (b *BlowfishCipher) Decrypt(dst, data []byte) error {
6364

6465
blockSize := b.cipher.BlockSize()
6566
if lenData%blockSize != 0 {
66-
return fmt.Errorf("encrypted data length must be a multiple of %d, got %d", blockSize, lenData)
67+
return fmt.Errorf("encrypted data len must be multiple of %d, got %d",
68+
blockSize, lenData)
6769
}
6870

6971
count := lenData / blockSize

internal/connect/crypt/blowfish_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestBlowfishDataNotMultipleOf8(t *testing.T) {
2929
if err == nil {
3030
t.Fatal("Decryption should have failed on data not multiple of 8")
3131
}
32-
expectedPrefix := "encrypted data length must be a multiple of 8"
32+
expectedPrefix := "encrypted data len must be multiple of 8"
3333
if !strings.HasPrefix(err.Error(), expectedPrefix) {
3434
t.Fatalf("Error message should start with '%s', got: %s", expectedPrefix, err.Error())
3535
}

internal/connect/crypt/random_unique_bench_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ func NewRandomSequenceOfUnique(seedBase, seedOffset uint32) RandomSequenceOfUniq
187187
}
188188

189189
func (r *RandomSequenceOfUnique) Next() uint32 {
190-
result := permuteQPR((permuteQPR(r.mIndex) + r.mIntermediateOffset) ^ 0x5bf03635)
190+
permutation := (permuteQPR(r.mIndex) + r.mIntermediateOffset) ^ 0x5bf03635
191+
result := permuteQPR(permutation)
191192
r.mIndex++
192193

193194
return result

internal/connect/helpers/hex_view.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ func HexASCIIViewFrom(data []byte) string {
8585
return sb.String()
8686
}
8787

88-
func HexViewFromWithLineSplit(data []byte, lineLength int, beforeLine string) string {
88+
func HexViewFromWithLineSplit(
89+
data []byte,
90+
lineLength int,
91+
beforeLine string,
92+
) string {
8993
var sb strings.Builder
9094
for i := 0; i < len(data); i += lineLength {
9195
sb.WriteString(beforeLine)

internal/connect/helpers/hex_view_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ func TestHexASCIIView(t *testing.T) {
5656
testData := testData()
5757
result := HexASCIIViewFrom(testData)
5858

59-
line1 := "0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................\n"
60-
line2 := "0010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................\n"
61-
line3 := "0020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e !\"#$%&'()*+,-. \n"
59+
line1 := "0000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................\n" //nolint:lll
60+
line2 := "0010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................\n" //nolint:lll
61+
line3 := "0020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e !\"#$%&'()*+,-. \n" //nolint:lll
6262
line4 := "Size: 47 bytes\n"
6363
expected := line1 + line2 + line3 + line4
6464

@@ -123,7 +123,8 @@ func TestHexStringFromInt32(t *testing.T) {
123123
t.Run(tt.name, func(t *testing.T) {
124124
result := HexStringFromInt32(tt.input)
125125
if result != tt.expected {
126-
t.Errorf("HexStringFromInt32(%d) = %s, want %s", tt.input, result, tt.expected)
126+
t.Errorf("HexStringFromInt32(%d) = %s, want %s",
127+
tt.input, result, tt.expected)
127128
}
128129
})
129130
}

internal/connect/packets/from_auth_server/init.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ func NewInitPacketFromBytes(data []byte) (*InitPacket, error) {
6868

6969
func (p *InitPacket) ToBytes(writer *packet.Writer) error { //nolint:cyclop
7070
if len(p.RsaPublicKey) != 128 {
71-
return fmt.Errorf("invalid RSA public key length: expected 128 bytes, got %d bytes", len(p.RsaPublicKey))
71+
return fmt.Errorf("invalid RSA public key len: %d bytes, expected 128",
72+
len(p.RsaPublicKey))
7273
}
7374
if err := writer.WriteInt32(p.SessionID); err != nil {
7475
return err

internal/connect/packets/from_auth_server/init_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func ExpectedRsaPublicKey() []byte {
5252
}
5353

5454
func convertBytesToInt32BigEndian(bytes []byte) int32 {
55-
//nolint:gosec // G115: Intentionally converting uint32 to int32 for test purposes
55+
//nolint:gosec
5656
return int32(binary.BigEndian.Uint32(bytes))
5757
}
5858

0 commit comments

Comments
 (0)