Skip to content

Commit 6754fe0

Browse files
committed
lints and more action issues
1 parent 5e47c30 commit 6754fe0

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ linters:
151151
min-complexity: 15
152152
cyclop:
153153
max-complexity: 15
154-
skip-tests: true
155154
nestif:
156155
min-complexity: 4
157156
varnamelen:

cmd/nfctest/discovery.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (d *Discovery) DiscoverReaders(ctx context.Context) ([]detection.DeviceInfo
6464
}
6565

6666
// CreateTransport creates the appropriate transport for a device
67-
func (d *Discovery) CreateTransport(reader detection.DeviceInfo) (pn532.Transport, error) {
67+
func (*Discovery) CreateTransport(reader detection.DeviceInfo) (pn532.Transport, error) {
6868
switch reader.Transport {
6969
case TransportUART:
7070
transport, err := uart.New(reader.Path)
@@ -90,7 +90,7 @@ func (d *Discovery) CreateTransport(reader detection.DeviceInfo) (pn532.Transpor
9090
}
9191

9292
// FindNewReaders finds readers that are new compared to the last scan
93-
func (d *Discovery) FindNewReaders(lastReaders, currentReaders []detection.DeviceInfo) []detection.DeviceInfo {
93+
func (*Discovery) FindNewReaders(lastReaders, currentReaders []detection.DeviceInfo) []detection.DeviceInfo {
9494
var newReaders []detection.DeviceInfo
9595

9696
for _, current := range currentReaders {
@@ -110,7 +110,7 @@ func (d *Discovery) FindNewReaders(lastReaders, currentReaders []detection.Devic
110110
}
111111

112112
// FindDisconnectedReaders finds readers that were present but are now gone
113-
func (d *Discovery) FindDisconnectedReaders(lastReaders, currentReaders []detection.DeviceInfo) []detection.DeviceInfo {
113+
func (*Discovery) FindDisconnectedReaders(lastReaders, currentReaders []detection.DeviceInfo) []detection.DeviceInfo {
114114
var disconnected []detection.DeviceInfo
115115

116116
for _, last := range lastReaders {

cmd/nfctest/monitoring.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func NewMonitoring(config *Config, output *Output, discovery *Discovery, testing
5050

5151
// MonitorCards continuously monitors for cards using proper InAutoPoll continuous polling
5252
func (m *Monitoring) MonitorCards(ctx context.Context, readers []detection.DeviceInfo, isQuick bool) error {
53-
fmt.Println("\nMonitoring for cards... (Ctrl+C to quit)")
53+
_, _ = fmt.Println("\nMonitoring for cards... (Ctrl+C to quit)")
5454

5555
setup, err := m.initializeDevices(readers)
5656
if err != nil {
@@ -148,7 +148,9 @@ func (m *Monitoring) startMonitoringLoop(ctx context.Context, setup *MonitoringS
148148
}
149149

150150
// continuousPolling runs continuous InAutoPoll monitoring for a single reader
151-
func (m *Monitoring) continuousPolling(ctx context.Context, device *pn532.Device, readerPath string, state *CardState, isQuick bool) error {
151+
func (m *Monitoring) continuousPolling(
152+
ctx context.Context, device *pn532.Device, readerPath string, state *CardState, isQuick bool,
153+
) error {
152154
for {
153155
select {
154156
case <-ctx.Done():
@@ -173,7 +175,7 @@ func (m *Monitoring) continuousPolling(ctx context.Context, device *pn532.Device
173175
}
174176

175177
// performSinglePoll performs a single tag detection cycle using the sophisticated strategy system
176-
func (m *Monitoring) performSinglePoll(ctx context.Context, device *pn532.Device) (*pn532.DetectedTag, error) {
178+
func (*Monitoring) performSinglePoll(ctx context.Context, device *pn532.Device) (*pn532.DetectedTag, error) {
177179
// Use short timeout for responsive card removal detection
178180
pollCtx, cancel := context.WithTimeout(ctx, 50*time.Millisecond)
179181
defer cancel()
@@ -212,15 +214,17 @@ func (m *Monitoring) handleCardRemoval(state *CardState, readerPath string) {
212214
}
213215

214216
// resetCardState resets the card state to empty
215-
func (m *Monitoring) resetCardState(state *CardState) {
217+
func (*Monitoring) resetCardState(state *CardState) {
216218
state.Present = false
217219
state.LastUID = ""
218220
state.LastType = ""
219221
state.TestedUID = ""
220222
}
221223

222224
// processPollingResults processes the detected tag
223-
func (m *Monitoring) processPollingResults(device *pn532.Device, detectedTag *pn532.DetectedTag, state *CardState, readerPath string, isQuick bool) {
225+
func (m *Monitoring) processPollingResults(
226+
device *pn532.Device, detectedTag *pn532.DetectedTag, state *CardState, readerPath string, isQuick bool,
227+
) {
224228
if detectedTag == nil {
225229
m.handleCardRemoval(state, readerPath)
226230
return
@@ -259,12 +263,14 @@ func (m *Monitoring) updateCardState(state *CardState, detectedTag *pn532.Detect
259263
}
260264

261265
// shouldTestCard determines if we should test the card
262-
func (m *Monitoring) shouldTestCard(state *CardState, currentUID string) bool {
266+
func (*Monitoring) shouldTestCard(state *CardState, currentUID string) bool {
263267
return state.TestedUID != currentUID
264268
}
265269

266270
// testAndRecordCard tests the card and records the result
267-
func (m *Monitoring) testAndRecordCard(device *pn532.Device, detectedTag *pn532.DetectedTag, state *CardState, isQuick bool) {
271+
func (m *Monitoring) testAndRecordCard(
272+
device *pn532.Device, detectedTag *pn532.DetectedTag, state *CardState, isQuick bool,
273+
) {
268274
if err := m.testing.TestCard(device, detectedTag, TestMode{Quick: isQuick}); err != nil {
269275
m.output.Error("Card test failed: %v", err)
270276
} else {
@@ -296,7 +302,7 @@ func (m *Monitoring) CheckCardsQuick(readers []detection.DeviceInfo) {
296302

297303
tags, err := device.DetectTags(1, 0x00)
298304
if err == nil && len(tags) > 0 {
299-
fmt.Printf("CARD: Card on %s: %s (UID: %s)\n",
305+
_, _ = fmt.Printf("CARD: Card on %s: %s (UID: %s)\n",
300306
reader.Path, tags[0].Type, tags[0].UID)
301307
}
302308

detection/uart/ports_windows.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func enrichWithUSBInfo(ports []serialPort) ([]serialPort, error) {
5959
setupDiGetClassDevs := setupapi.NewProc("SetupDiGetClassDevsW")
6060
setupDiEnumDeviceInfo := setupapi.NewProc("SetupDiEnumDeviceInfo")
6161
setupDiGetDeviceRegistryProperty := setupapi.NewProc("SetupDiGetDeviceRegistryPropertyW")
62-
setupDiGetDeviceInstanceId := setupapi.NewProc("SetupDiGetDeviceInstanceIdW")
6362
setupDiDestroyDeviceInfoList := setupapi.NewProc("SetupDiDestroyDeviceInfoList")
6463

6564
// GUID for Ports class
@@ -124,7 +123,7 @@ func enrichWithUSBInfo(ports []serialPort) ([]serialPort, error) {
124123
SPDRP_FRIENDLYNAME,
125124
uintptr(unsafe.Pointer(&propertyType)),
126125
uintptr(unsafe.Pointer(&friendlyName[0])),
127-
uint32(len(friendlyName)*2),
126+
uintptr(uint32(len(friendlyName)*2)),
128127
uintptr(unsafe.Pointer(&size)),
129128
)
130129

@@ -162,7 +161,7 @@ func enrichWithUSBInfo(ports []serialPort) ([]serialPort, error) {
162161
SPDRP_HARDWAREID,
163162
uintptr(unsafe.Pointer(&propertyType)),
164163
uintptr(unsafe.Pointer(&hardwareID[0])),
165-
uint32(len(hardwareID)*2),
164+
uintptr(uint32(len(hardwareID)*2)),
166165
uintptr(unsafe.Pointer(&size)),
167166
)
168167

@@ -184,7 +183,7 @@ func enrichWithUSBInfo(ports []serialPort) ([]serialPort, error) {
184183
SPDRP_MFG,
185184
uintptr(unsafe.Pointer(&propertyType)),
186185
uintptr(unsafe.Pointer(&mfg[0])),
187-
uint32(len(mfg)*2),
186+
uintptr(uint32(len(mfg)*2)),
188187
uintptr(unsafe.Pointer(&size)),
189188
)
190189

ntag.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ func (t *NTAGTag) readNDEFBlockByBlock() (*NDEFMessage, error) {
368368
if i > 255 {
369369
break // Prevent overflow
370370
}
371-
blockData, err := t.readBlockWithRetry(uint8(i))
371+
// Safe conversion: i is checked to be <= 255
372+
blockData, err := t.readBlockWithRetry(uint8(i)) // #nosec G115
372373
if err != nil {
373374
break
374375
}

0 commit comments

Comments
 (0)