Open teunbrand opened 4 months ago
Agree it's a good idea for a linter, but will be ~relatively tough to implement -- really it's something {codetools} is best suited for since it requires a strong sense of scope to get match.fun() working with sufficient accuracy to be useful (I reckon). Then like object_usage_linter() we'd pull out info from the codetools report.
I thought it might be handy to have a linter that checks for the pattern
fun(x, y, ...)
wherex
andy
are unnamed arguments and are matched tofun()
based on their position. This is risky to combine with...
as a named argument in...
might supplantx
ory
and shift subsequent arguments.To illustrate, this piece of code with named arguments correctly gives the 'matched by multiple arguments' error:
However, if we don't use named arguments we get into the following trouble. Note that
num = 5
is passed through...
which means that the 2nd default argument (4) that is supposed to be thenum
argument is now shifted to thelgl
argument.Created on 2024-07-10 with reprex v2.1.0
For this reason, I think it'd be good to recommend naming arguments when combined with
...
.