Skip to content

test: impossible nil != nil conditions and unused symbols in logpattern test/mock files #20

@mattmattox

Description

@mattmattox

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions