Several push calls in a row add to the same array, where one call takes all the values
What it finds
push accepts any number of elements. Consecutive calls on the same array, each with one value, can be combined into one call that shows the values together.
Reported are push statements that directly follow a push statement on the same array.
From the rule's source, consecutive_push_calls.rs.
export function build() { const out: number[] = []; out.push(1); out.push(2);tx0 reports: this push could be combined with the one before return out;} Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:consecutive-push-calls" = "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/ts:consecutive-push-calls] reason="..."tx0 explain tx0/ts:consecutive-push-calls shows the same in the terminal. Found a false positive? Report it.