append is called with a slice and nothing to append

tx0/go:append-nothingdefaultwarningbug

What it finds

s = append(s): with no values after the slice, append returns the slice unchanged, so the statement does nothing. Usually the value to append was forgotten, or ... is missing after a second slice that was dropped in an edit.

The call must be of the builtin append with exactly one argument and no ....

From the rule's source, append_nothing.rs.

Example from the rule's tests
package p func f(s []int, t []int) []int {	s = append(s)tx0 reports: append with nothing to append returns the slice unchanged	s = append(s, 1)	s = append(s, t...)	return append([]int(nil), s...)}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

tx0.toml
[rules]
"tx0/go:append-nothing" = "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:append-nothing] reason="..."

tx0 explain tx0/go:append-nothing shows the same in the terminal. Found a false positive? Report it.