The set of characters given to Trim, TrimLeft or TrimRight repeats a character, as a prefix or suffix would
What it finds
strings.TrimLeft(s, "http://"): the second argument is a set of characters, and TrimLeft removes every leading character that is in the set, so it turns "https://tx0.dev" into "s://tx0.dev" and "t.go" into ".go". A set that names a character twice is almost always a prefix or suffix written as a set; TrimPrefix and TrimSuffix remove exactly one.
The set must be a constant string of the file, and the function Trim, TrimLeft or TrimRight of strings or bytes, resolved through the imports.
From the rule's source, trim_cutset_repeats.rs.
package p import "strings" const scheme = "https://" func f(s string) []string { return []string{ strings.TrimLeft(s, "http://"),tx0 reports: the set of characters for strings.TrimLeft names t twice strings.TrimRight(s, ".pb.go"),tx0 reports: the set of characters for strings.TrimRight names . twice strings.Trim(s, scheme),tx0 reports: the set of characters for strings.Trim names t twice strings.TrimLeft(s, " \t"), strings.TrimRight(s, "\r\n"), strings.TrimPrefix(s, "http://"), strings.Trim(s, s+s), }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/go:trim-cutset-repeats" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/go:trim-cutset-repeats] reason="..."tx0 explain tx0/go:trim-cutset-repeats shows the same in the terminal. Found a false positive? Report it.