A remainder is taken of a division by 1, which is always 0
What it finds
i % 1 == 0: the remainder of an integer divided by 1 is always 0, so the expression does not depend on i. Another divisor, often 2 or a variable, was meant.
Reported are % and %= with the integer literal 1 as the divisor.
From the rule's source, modulo_one.rs.
package p func f(i int) bool { j := i % 2 j %= 1tx0 reports: the remainder of a division by 1 is always 0 return i%1 == 0 || j == 0tx0 reports: the remainder of a division by 1 is always 0} 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:modulo-one" = "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:modulo-one] reason="..."tx0 explain tx0/go:modulo-one shows the same in the terminal. Found a false positive? Report it.