Two statements are written on one line, separated by a semicolon

tx0/go:semicolon-joined-statementsstrictwarningstyle

What it finds

x := 1; y := 2: two statements on one line are easy to miss when reading, a debugger stops on the line rather than on each, and a diff of either changes both. gofmt keeps them as written, so the rule finds them.

Reported is a statement that follows a written ; on the same line, inside a block or a case. The clauses of if, for and switch headers are not statements of a block and are left alone.

From the rule's source, semicolon_joined_statements.rs.

Example from the rule's tests
package p func f() int {	x := 1; y := 2tx0 reports: this statement shares its line with the one before	for i := 0; i < 3; i++ {		x += i	}	return x + y}
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 from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

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

tx0 explain tx0/go:semicolon-joined-statements shows the same in the terminal. Found a false positive? Report it.