Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A new linter checking duplicate arguments #850

Closed
renkun-ken opened this issue Aug 17, 2021 · 2 comments · Fixed by #851
Closed

A new linter checking duplicate arguments #850

renkun-ken opened this issue Aug 17, 2021 · 2 comments · Fixed by #851

Comments

@renkun-ken
Copy link
Collaborator

It is almost always a mistake to call a function with duplicate arguments, i.e. arguments of the same name, like the following:

foo(bar1 = 1, bar1 = 2, bar3 = 3)

Therefore, in most cases, it might make sense to check all function calls and ensure there are no duplicate arguments.

One use case of duplicate argument is to produce some table that actually needs duplicate headers for demonstration in documents, e.g.

data <- data.frame(
  mean = 1:5,
  sd = 0.5,
  mean = 2:6,
  sd = 1,
  check.names = FALSE
)
@MichaelChirico
Copy link
Collaborator

do we want to maintain an allowlist of functions where duplicates are allowed? data.frame(), data.table(), c(), list(), tibble() & compatriots, ...

@renkun-ken
Copy link
Collaborator Author

renkun-ken commented Aug 17, 2021

I think just like missing_argument_linter(except = c(...)) would be enough. But I suspect even these functions should not be allowed by default too because in most scenarios using duplicate arguments with these functions are undesired either, except for a very limited scenarios where it might be useful I like mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants