Summary
Static analysis (staticcheck / nilness) reports quality issues in logpattern test and mock files.
Issues
impossible condition: nil != nil (nilness analyser)
logpattern_stress_test.go: lines 89, 226, 332, 458, 576, 679, 785
logpattern_security_test.go: lines 186, 369, 486, 616, 699, 898
These are dead-code guards that can never execute. Likely a copy-paste error where the variable being checked was changed to a value type but the nil comparison was left behind.
Unused writes to struct fields (logpattern_security_test.go lines 785–788)
config.Patterns = ... // written but never read
config.JournalUnits = ... // written but never read
config.MaxEventsPerPattern = ... // written but never read
config.DedupWindow = ... // written but never read
Unused symbols (logpattern_mocks.go)
- Line 203: method
getCalls — defined but never called
- Line 208: method
wasCalled — defined but never called
- Line 238: const
testKernelPanicLog — defined but never referenced
Steps to Reproduce
go vet ./pkg/monitors/custom/...
staticcheck ./pkg/monitors/custom/...
Suggested Action
- Fix nil checks to compare the correct variable, or remove if the guard is no longer needed.
- Remove or actually exercise the unused fields/methods/const.
- Add
staticcheck to CI to catch these going forward.
Summary
Static analysis (
staticcheck/nilness) reports quality issues in logpattern test and mock files.Issues
impossible condition: nil != nil(nilness analyser)logpattern_stress_test.go: lines 89, 226, 332, 458, 576, 679, 785logpattern_security_test.go: lines 186, 369, 486, 616, 699, 898These are dead-code guards that can never execute. Likely a copy-paste error where the variable being checked was changed to a value type but the nil comparison was left behind.
Unused writes to struct fields (
logpattern_security_test.golines 785–788)Unused symbols (
logpattern_mocks.go)getCalls— defined but never calledwasCalled— defined but never calledtestKernelPanicLog— defined but never referencedSteps to Reproduce
Suggested Action
staticcheckto CI to catch these going forward.