You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The trimleftright linter in pkg/linters/trimleftright/trimleftright.go fires only when a cutset contains a repeated rune (e.g., TrimLeft(s, "foo") triggers because 'o' repeats). This misses the most common real instances of the bug — distinct-char strings like "http", "bar", "abc", "0x", "prefix" — which are exactly the patterns where users confuse TrimLeft/TrimRight with TrimPrefix/TrimSuffix.
The repeated-rune guard adds nothing to false-positive avoidance (the all-alphanumeric guard already handles whitespace character classes) and only removes true positives. The testdata in goodNoRepeatedAlnum canonizes this broken behavior as intentional.
Suggested Changes
Replace the repeated-rune trigger in looksSuspiciousCutset with a class-aware discriminator
Flag all multi-rune alphanumeric cutsets except recognized class idioms (contiguous ranges, hex digits, digit sets like "0123456789", vowel sets like "aeiou")
Update testdata/trimleftright.go to expect diagnostics for TrimLeft(s, "http"), TrimLeft(s, "abc"), TrimLeft(s, "txt")
Keep TrimLeft(s, "aeiou"), TrimLeft(s, "0123456789"), TrimLeft(s, "abcdef") as passing (recognized class patterns)
Or document the narrow scope explicitly in the linter README if intentional
Activity
github-actions commentedon Jul 20, 2026
This issue was automatically closed because it expired on 2026-07-20T07:45:31.108Z.
github-actions commentedon Jul 20, 2026
This issue was automatically closed because it expired on 2026-07-20T07:45:31.108Z.
github-actions commentedon Jul 20, 2026
This issue was automatically closed because it expired on 2026-07-20T07:45:31.108Z.
github-actions commentedon Jul 20, 2026
This issue was automatically closed because it expired on 2026-07-20T07:45:31.108Z.