Skip to content

fix(go): reduce false positives in Go slop patterns#25

Merged
avifenesh merged 1 commit intomainfrom
fix/go-pattern-false-positives
Feb 26, 2026
Merged

fix(go): reduce false positives in Go slop patterns#25
avifenesh merged 1 commit intomainfrom
fix/go-pattern-false-positives

Conversation

@avifenesh
Copy link
Contributor

Summary

  • Add comment-line guards to 4 debugging/exit patterns (skip // lines)
  • Change go_discarded_error to line-start anchor (exclude multi-return assignments)
  • Add false positive tests for all tuned patterns

Tested against gin, echo, cobra, zap - reduced FPs from 78 to 40 (-49%).

Test Plan

  • 2366 tests pass
  • Scanned gin, echo, cobra, zap before/after to measure FP reduction
  • No regressions in existing pattern detection

…iscards

Tested against gin, echo, cobra, zap - reduced FPs from 78 to 40 (-49%).

- Add ^(?!\s*\/\/) comment-line guard to go_fmt_debugging, go_log_debugging,
  go_spew_debugging, go_bare_os_exit patterns
- Change go_discarded_error to ^\s*_ anchor - only matches when _ is the
  first token on the line, excluding multi-return assignments like
  value, _ = func() and _, _ = fmt.Fprintf(...)
- Add false positive tests for all tuned patterns
@avifenesh avifenesh merged commit 9905c3d into main Feb 26, 2026
3 checks passed
@avifenesh avifenesh deleted the fix/go-pattern-false-positives branch February 26, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant