A function has more lines of code than the configured maximum

tx0/go:long-functionrecommendedwarningmaintainability

What it finds

A function that runs over many screens is hard to hold in mind at once: its variables live long, its cases interleave, and a change in one part affects others in ways that are easy to miss. Splitting it along the steps it takes gives each step a name and a boundary.

The length is counted in lines of code from the func keyword to the closing brace: lines with at least one token, so blank lines and lines with only comments do not count. Function literals count toward the function they are written in. The maximum is the parameter max_lines, 100 by default.

From the rule's source, long_function.rs.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

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

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