-
Notifications
You must be signed in to change notification settings - Fork 185
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
R6 method chaining #2813
Comments
Could you provide a reproducible example? I'm not seeing any lints from copy-pasting yours: l = modify_defaults(all_linters(), implicit_integer_linter = NULL)
lint("
x$
add(10)$
add(10)$
sum
", linters = l)
# ℹ No lints found. |
Sorry! I didn't realise having or not method parameters would make a difference. r$> l = modify_defaults(all_linters(), implicit_integer_linter = NULL)
lint("
x$
add()$
add()$
sum
", linters = l)
# Output:
<text>:2:2: warning: [extraction_operator_linter] Use `[[` instead of `$` to extract an element.
x$
^
<text>:3:2: style: [indentation_linter] Indentation should be 0 spaces but is 2 spaces.
add()$
~^
<text>:3:8: warning: [extraction_operator_linter] Use `[[` instead of `$` to extract an element.
add()$
^
<text>:4:8: warning: [extraction_operator_linter] Use `[[` instead of `$` to extract an element.
add()$
^ |
can you try updating to current dev version? extraction_operator_linter() is deprecated so I suspect you're on an old version |
Updating to the newest version on CRAN (3.2.0) changes the result to this: l = modify_defaults(all_linters(), implicit_integer_linter = NULL)
lint("
x$
add()$
add()$
sum
", linters = l)
# <text>:3:2: style: [indentation_linter] Indentation should be 0 spaces but is 2 spaces.
# add()$
# ~^ |
Thanks, I confirm the issue. Not sure why my earlier example didn't spot it. |
I think it only happens if there's no parameter in the functions used, if you pass a parameter then it goes back to no lints found. |
Is there a way to get the linter to recognize R6 method chaining and not complain?
https://adv-r.hadley.nz/r6.html#method-chaining
When I try to lay out code like this:
It complains about incorrect numbers of indents.
The text was updated successfully, but these errors were encountered: