feat: remove nolint

This commit is contained in:
zarazaex69
2026-05-10 23:02:00 +03:00
parent 50157fd50c
commit f6b82da099
52 changed files with 43 additions and 90 deletions

View File

@@ -25,10 +25,8 @@ const modeGen = "gen"
// ErrDataDirRequired is returned when no data directory is specified.
var ErrDataDirRequired = errors.New("data directory required (use -data data)")
//nolint:gochecknoglobals // Tests replace the long-running session runner with a bounded function.
var runSession = session.Run
//nolint:gochecknoglobals // Tests replace gen runner with a stub.
var runGen = execGen
type config struct {

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package main
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package session
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package builtin
import (

View File

@@ -49,7 +49,6 @@ type Config struct {
// Factory creates a new carrier session.
type Factory func(ctx context.Context, cfg Config) (Session, error)
//nolint:gochecknoglobals
var registry = make(map[string]Factory)
// Register adds a carrier factory to the registry.

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package client
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package e2e
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package direct
import (

View File

@@ -55,7 +55,6 @@ type Config struct {
// Factory creates a link instance.
type Factory func(ctx context.Context, cfg Config) (Link, error)
//nolint:gochecknoglobals
var registry = make(map[string]Factory)
// Register adds a link factory to the registry.

View File

@@ -9,14 +9,14 @@ import (
type stubLink struct{}
func (s *stubLink) Connect(context.Context) error { return nil }
func (s *stubLink) Send([]byte) error { return nil }
func (s *stubLink) Close() error { return nil }
func (s *stubLink) SetReconnectCallback(func()) {}
func (s *stubLink) SetShouldReconnect(func() bool) {}
func (s *stubLink) SetEndedCallback(func(string)) {}
func (s *stubLink) WatchConnection(context.Context) {}
func (s *stubLink) CanSend() bool { return true }
func (s *stubLink) Connect(context.Context) error { return nil }
func (s *stubLink) Send([]byte) error { return nil }
func (s *stubLink) Close() error { return nil }
func (s *stubLink) SetReconnectCallback(func()) {}
func (s *stubLink) SetShouldReconnect(func() bool) {}
func (s *stubLink) SetEndedCallback(func(string)) {}
func (s *stubLink) WatchConnection(context.Context) {}
func (s *stubLink) CanSend() bool { return true }
func snapshotLinkRegistry() map[string]Factory {
out := make(map[string]Factory, len(registry))

View File

@@ -7,8 +7,6 @@ import (
)
// verboseEnabled controls whether verbose and debug logging is enabled.
//
//nolint:gochecknoglobals // Global log state is acceptable for CLI tools.
var verboseEnabled atomic.Bool
// SetVerbose enables or disables verbose/debug logging.

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package muxconn
import (

View File

@@ -17,7 +17,6 @@ var embeddedNames string
//go:embed data/surnames
var embeddedSurnames string
//nolint:gochecknoglobals // Package-level state keeps the loaded name dictionaries cached for the process lifetime.
var (
firstNames = parseEmbedded(embeddedNames)
lastNames = parseEmbedded(embeddedSurnames)
@@ -36,7 +35,6 @@ func parseEmbedded(raw string) []string {
}
func loadNames(path string) ([]string, error) {
//nolint:gosec // Paths come from local CLI/runtime configuration; loading override files is intentional here.
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("open names file %q: %w", path, err)

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package names
import (

View File

@@ -12,7 +12,7 @@ import (
// Protector is called with a socket file descriptor before connect.
// On Android, this calls VpnService.protect(fd) to bypass VPN routing.
var Protector func(fd int) bool //nolint:gochecknoglobals
var Protector func(fd int) bool
func controlFunc(network, _ string, c syscall.RawConn) error {
if Protector == nil {
@@ -47,7 +47,7 @@ func NewHTTPClient() *http.Client {
ForceAttemptHTTP2: true,
MaxIdleConns: 10,
IdleConnTimeout: 30 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ResponseHeaderTimeout: 10 * time.Second,
}
return &http.Client{Transport: transport}
@@ -78,4 +78,3 @@ func (d *ProxyDialer) Dial(network, addr string) (net.Conn, error) {
func NewProxyDialer() *ProxyDialer {
return &ProxyDialer{}
}

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package protect
import (

View File

@@ -20,7 +20,7 @@ const (
contentTypeJSON = "application/json"
)
var apiBase = "https://bk.salutejazz.ru" //nolint:gochecknoglobals // Tests redirect HTTP API calls to httptest.
var apiBase = "https://bk.salutejazz.ru"
// RoomInfo contains connection details for a SaluteJazz room.
type RoomInfo struct {

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package jazz
import (

View File

@@ -16,7 +16,7 @@ func encodeVarint(value uint64) []byte {
}
func encodeField(fieldNumber int, wireType int, data []byte) []byte {
tag := encodeVarint(uint64(fieldNumber)<<3 | uint64(wireType)) //nolint:gosec
tag := encodeVarint(uint64(fieldNumber)<<3 | uint64(wireType))
switch wireType {
case 2:
length := encodeVarint(uint64(len(data)))
@@ -101,12 +101,12 @@ func handleWireType(reader *byteReader, wireType int, dataLen int) ([]byte, bool
if err != nil {
return nil, false
}
if length > uint64(dataLen)-uint64(reader.pos) { //nolint:gosec
if length > uint64(dataLen)-uint64(reader.pos) {
return nil, false
}
fieldData := make([]byte, length)
n, err := reader.Read(fieldData)
if err != nil || uint64(n) != length { //nolint:gosec
if err != nil || uint64(n) != length {
return nil, false
}
return fieldData, true

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package jazz
import (

View File

@@ -13,21 +13,20 @@ import (
"github.com/openlibrecommunity/olcrtc/internal/protect"
)
//nolint:gochecknoglobals // Tests redirect HTTP API calls to httptest.
var apiBase = "https://cloud-api.yandex.ru/telemost_front/v2/telemost"
var ErrAPI = errors.New("api error") //nolint:revive
var ErrAPI = errors.New("api error")
type ConnectionInfo struct { //nolint:revive
RoomID string `json:"room_id"` //nolint:tagliatelle
PeerID string `json:"peer_id"` //nolint:tagliatelle
Credentials string `json:"credentials"` //nolint:tagliatelle
type ConnectionInfo struct {
RoomID string `json:"room_id"`
PeerID string `json:"peer_id"`
Credentials string `json:"credentials"`
ClientConfig struct {
MediaServerURL string `json:"media_server_url"` //nolint:tagliatelle
} `json:"client_configuration"` //nolint:tagliatelle
MediaServerURL string `json:"media_server_url"`
} `json:"client_configuration"`
}
func GetConnectionInfo(ctx context.Context, roomURL, displayName string) (*ConnectionInfo, error) { //nolint:revive
func GetConnectionInfo(ctx context.Context, roomURL, displayName string) (*ConnectionInfo, error) {
u := fmt.Sprintf("%s/conferences/%s/connection", apiBase, url.QueryEscape(roomURL))
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package telemost
import (

View File

@@ -1469,7 +1469,6 @@ func (p *Peer) calculateDelay() time.Duration {
if maxDelay <= minDelay {
return minDelay
}
//nolint:gosec
return minDelay + time.Duration(rand.Int64N(int64(maxDelay-minDelay)))
}

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package telemost
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package telemost
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package telemost
import (

View File

@@ -12,7 +12,7 @@ import (
"github.com/openlibrecommunity/olcrtc/internal/protect"
)
var apiBase = "https://stream.wb.ru" //nolint:gochecknoglobals // Tests redirect HTTP API calls to httptest.
var apiBase = "https://stream.wb.ru"
var (
errGuestRegister = errors.New("guest register failed")

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package wbstream
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package wbstream
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package wbstream
import (

View File

@@ -481,7 +481,7 @@ func (s *Server) socks5Connect(conn net.Conn, targetAddr string, targetPort int)
req := make([]byte, 0, 7+addrLen)
req = append(req, 5, 1, 0, 3, byte(addrLen))
req = append(req, []byte(targetAddr)...)
req = append(req, byte(targetPort>>8), byte(targetPort)) //nolint:gosec
req = append(req, byte(targetPort>>8), byte(targetPort))
if _, err := conn.Write(req); err != nil {
return fmt.Errorf("failed to write socks5 connect req: %w", err)

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package server
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package datachannel
import (

View File

@@ -16,7 +16,6 @@ var (
ErrSEIValueTruncated = errors.New("sei value truncated")
)
//nolint:gochecknoglobals
var (
videoSEIUUID = [16]byte{
0x5d, 0xc0, 0x3b, 0xa8,
@@ -135,7 +134,7 @@ func appendSEIValue(dst []byte, value int) []byte {
dst = append(dst, 0xff)
value -= 0xff
}
return append(dst, byte(value)) //nolint:gosec
return append(dst, byte(value))
}
func consumeSEIValue(data []byte, pos int) (int, int, error) {

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package seichannel
import (

View File

@@ -471,7 +471,7 @@ func (p *streamTransport) assembleMessage(msg *inboundMessage) []byte {
for _, frag := range msg.frags {
data = append(data, frag...)
}
if uint32(len(data)) > msg.totalLen { //nolint:gosec
if uint32(len(data)) > msg.totalLen {
data = data[:msg.totalLen]
}
return data
@@ -557,9 +557,9 @@ func encodeDataFrame(seq, crc uint32, totalLen, fragIdx, fragTotal int, payload
out[5] = frameTypeData
binary.BigEndian.PutUint32(out[6:10], seq)
binary.BigEndian.PutUint32(out[10:14], crc)
binary.BigEndian.PutUint32(out[14:18], uint32(totalLen)) //nolint:gosec
binary.BigEndian.PutUint16(out[18:20], uint16(fragIdx)) //nolint:gosec
binary.BigEndian.PutUint16(out[20:22], uint16(fragTotal)) //nolint:gosec
binary.BigEndian.PutUint32(out[14:18], uint32(totalLen))
binary.BigEndian.PutUint16(out[18:20], uint16(fragIdx))
binary.BigEndian.PutUint16(out[20:22], uint16(fragTotal))
copy(out[22:], payload)
return out
}

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package seichannel
import (

View File

@@ -63,7 +63,6 @@ type Config struct {
// Factory creates a transport instance.
type Factory func(ctx context.Context, cfg Config) (Transport, error)
//nolint:gochecknoglobals
var registry = make(map[string]Factory)
// Register adds a transport factory to the registry.

View File

@@ -202,7 +202,7 @@ func newFFmpegEncoder(
vcodec := resolveEncoderCodec(spec, hw)
args := buildEncoderArgs(spec, vcodec, width, height, fps, bitrate)
cmd := exec.CommandContext(ctx, "ffmpeg", args...) //nolint:gosec
cmd := exec.CommandContext(ctx, "ffmpeg", args...)
stdin, err := cmd.StdinPipe()
if err != nil {
return nil, fmt.Errorf("encoder stdin: %w", err)
@@ -404,7 +404,7 @@ func newFFmpegDecoder(
decoderName := resolveDecoderName(spec, hw)
args := buildDecoderArgs(spec, decoderName, width, height, "gray")
cmd := exec.CommandContext(ctx, "ffmpeg", args...) //nolint:gosec
cmd := exec.CommandContext(ctx, "ffmpeg", args...)
stdin, err := cmd.StdinPipe()
if err != nil {
return nil, fmt.Errorf("decoder stdin: %w", err)
@@ -539,9 +539,9 @@ func writeIVFHeader(w io.Writer, fourCC string, width, height, frameRate int) er
binary.LittleEndian.PutUint16(header[4:6], 0)
binary.LittleEndian.PutUint16(header[6:8], 32)
copy(header[8:12], []byte(fourCC))
binary.LittleEndian.PutUint16(header[12:14], uint16(width)) //nolint:gosec
binary.LittleEndian.PutUint16(header[14:16], uint16(height)) //nolint:gosec
binary.LittleEndian.PutUint32(header[16:20], uint32(frameRate)) //nolint:gosec
binary.LittleEndian.PutUint16(header[12:14], uint16(width))
binary.LittleEndian.PutUint16(header[14:16], uint16(height))
binary.LittleEndian.PutUint32(header[16:20], uint32(frameRate))
binary.LittleEndian.PutUint32(header[20:24], 1)
binary.LittleEndian.PutUint32(header[24:28], 0)
binary.LittleEndian.PutUint32(header[28:32], 0)
@@ -550,7 +550,7 @@ func writeIVFHeader(w io.Writer, fourCC string, width, height, frameRate int) er
func writeIVFFrame(w io.Writer, pts uint64, frame []byte) error {
header := make([]byte, 12)
binary.LittleEndian.PutUint32(header[0:4], uint32(len(frame))) //nolint:gosec
binary.LittleEndian.PutUint32(header[0:4], uint32(len(frame)))
binary.LittleEndian.PutUint64(header[4:12], pts)
if err := writeAll(w, header); err != nil {
return err

View File

@@ -71,9 +71,9 @@ func encodeDataFrame(seq, crc uint32, totalLen, fragIdx, fragTotal int, payload
out[5] = frameTypeData
binary.BigEndian.PutUint32(out[6:10], seq)
binary.BigEndian.PutUint32(out[10:14], crc)
binary.BigEndian.PutUint32(out[14:18], uint32(totalLen)) //nolint:gosec
binary.BigEndian.PutUint16(out[18:20], uint16(fragIdx)) //nolint:gosec
binary.BigEndian.PutUint16(out[20:22], uint16(fragTotal)) //nolint:gosec
binary.BigEndian.PutUint32(out[14:18], uint32(totalLen))
binary.BigEndian.PutUint16(out[18:20], uint16(fragIdx))
binary.BigEndian.PutUint16(out[20:22], uint16(fragTotal))
copy(out[22:], payload)
return out
}

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package videochannel
import (

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package videochannel
import (

View File

@@ -70,7 +70,7 @@ type streamTransport struct {
videoCodec string
videoTileModule int
videoTileRS int
runCtx context.Context //nolint:containedctx
runCtx context.Context
idleFrame []byte
idleFrameMu sync.Mutex
@@ -571,7 +571,7 @@ func (p *streamTransport) assembleMessage(msg *inboundMessage) []byte {
for _, frag := range msg.frags {
data = append(data, frag...)
}
if uint32(len(data)) > msg.totalLen { //nolint:gosec
if uint32(len(data)) > msg.totalLen {
data = data[:msg.totalLen]
}
return data

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package videochannel
import (

View File

@@ -129,7 +129,7 @@ func extractTilePayload(frame []byte, tileModule, tileRS int) ([]byte, error) {
result, err := c.Decode(frame)
if err != nil {
return nil, nil //nolint:nilerr
return nil, nil
}
return result.Payload, nil

View File

@@ -134,7 +134,6 @@ func (r *kcpRuntime) send(msg []byte) error {
return ErrKCPMessageTooLarge
}
var hdr [kcpLenPrefix]byte
//nolint:gosec
binary.BigEndian.PutUint32(hdr[:], uint32(len(msg)))
r.writeMu.Lock()

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package vp8channel
import (

View File

@@ -62,7 +62,6 @@ var (
ErrTransportClosed = errors.New("vp8channel transport closed")
)
//nolint:gochecknoglobals
var vp8Keepalive = []byte{
0x30, 0x01, 0x00, 0x9d, 0x01, 0x2a, 0x10, 0x00,
0x10, 0x00, 0x00, 0x47, 0x08, 0x85, 0x85, 0x88,
@@ -213,7 +212,6 @@ func randomEpoch() uint32 {
if _, err := rand.Read(b[:]); err != nil {
// rand.Read on Linux essentially never fails; fall back to a
// time-derived value rather than panic.
//nolint:gosec // intentional uint32 truncation of a nanosecond timestamp
return uint32(time.Now().UnixNano())
}
e := binary.BigEndian.Uint32(b[:])

View File

@@ -122,8 +122,8 @@ func testEpochHdr(epoch uint32) [epochHdrLen]byte {
func TestHandleIncomingFrameIgnoresLoopedBackLocalEpoch(t *testing.T) {
tr := &streamTransport{
bindingToken: bindingToken("test"),
localEpoch: 12345,
onData: func([]byte) {},
localEpoch: 12345,
onData: func([]byte) {},
}
var called atomic.Int32

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package vp8channel
import (

View File

@@ -64,7 +64,6 @@ const (
httpPingSampleDelay = 80 * time.Millisecond
)
//nolint:gochecknoglobals // Mobile bindings expose a singleton runtime controlled by the embedding app.
var (
mu sync.Mutex
defaults mobileConfig
@@ -617,8 +616,6 @@ func startWithConfig(
}
// WaitReady blocks until the selected transport is connected and the local SOCKS5 listener is ready.
//
//nolint:cyclop // The control flow is intentionally linear so mobile callers can observe each startup state clearly.
func WaitReady(timeoutMillis int) error {
mu.Lock()
r := ready

View File

@@ -1,4 +1,3 @@
//nolint:all // Test file keeps scenario setup inline.
package mobile
import (