lintr icon indicating copy to clipboard operation
lintr copied to clipboard

(WIP) Allows the use of = instead of <-

Open J-Moravec opened this issue 1 year ago • 20 comments

This is a tiny change that solves https://github.com/r-lib/lintr/issues/2441.

By adding allow_equal_assignment parameter to the assignment_linter which defaults to FALSE, we give an option to use = instead of <-.

Associated tests are passing. Some other non-associated tests are failing though. But that seems unrelated.

Potential improvements:

  • perhaps a better name would be equality instead of equal? The latter might be already in use.
  • I modified only xpath not trailing_assign_xpath. Since the linter assumes <- instead of = by default, the trailing_assign_xpath might warrant changes as well. But this goes above my current knowledge of how linters actually work.

Review is warranted.

Thanks.

edit: Fixed issues highlighted by github actions (didn't run document() and lintr and force-pushed. For some reason, test-lint_dir fails for me, but doesn't file on github actions:

Error (test-lint_dir.R:98:3): lint_dir works with specific linters without specifying other arguments
Error: Found unknown arguments in ...: NA.

Error (test-lint_dir.R:107:3): linting empty directory passes
Error: Found unknown arguments in ...: NA.

and lintr::lint_package() complained about not being able to read the .lintr config, but it somehow works now so I have no idea why it failed in the first place.

J-Moravec avatar Feb 21 '24 20:02 J-Moravec