make is given a capacity or buffer size that is the default anyway
What it finds
make([]int, n, n) or make(chan int, 0): the capacity of a slice defaults to its length and a channel is unbuffered by default, so these arguments repeat the default and only make the reader check that they do.
Reported are calls of the builtin make whose capacity is the same expression, without calls, as the length, and calls that make a channel with the literal size 0. The fix removes the argument, which keeps what the call does, so it is safe.
From the rule's source, redundant_make_capacity.rs.
package p func f(n int) ([]int, chan int, []int) { a := make([]int, n, n)tx0 reports: the capacity is the length by default c := make(chan int, 0)tx0 reports: a channel is unbuffered without a size of 0 b := make([]int, 0, n) return a, c, b} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/go:redundant-make-capacity" = "warning"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:redundant-make-capacity] reason="..."tx0 explain tx0/go:redundant-make-capacity shows the same in the terminal. Found a false positive? Report it.