-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
add assignment_as_infix = TRUE to indentation_linter() #1812
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1812 +/- ##
=======================================
Coverage 98.86% 98.86%
=======================================
Files 112 112
Lines 4841 4852 +11
=======================================
+ Hits 4786 4797 +11
Misses 55 55
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Link rot check is getting HTTP 500s at the moment. All other checks pass ✔️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Thanks for your feedback. I hope the comment is more clear on how the XPath works now. |
@MichaelChirico LMK when you have the time to review. I want to avoid spamming merges. |
@@ -97,7 +118,8 @@ | |||
#' - <https://style.tidyverse.org/functions.html#long-lines-1> | |||
#' | |||
#' @export | |||
indentation_linter <- function(indent = 2L, hanging_indent_style = c("tidy", "always", "never")) { | |||
indentation_linter <- function(indent = 2L, hanging_indent_style = c("tidy", "always", "never"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i usually prefer each argument with defaults on its own line once >1 line is used, WDYT? not sure it's a stated rule, but it's similar to the long lines rule for calls.
@@ -261,6 +297,16 @@ indentation_linter <- function(indent = 2L, hanging_indent_style = c("tidy", "al | |||
}) | |||
} | |||
|
|||
find_new_indent <- function(current_indent, change_type, indent, hanging_indent) { | |||
if (change_type == "hanging") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe a switch()
is more appropriate? change_type
feels pretty enum
-like
") | ||
|
||
# test brace restorator | ||
code_infix_3 <- trim_some(" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's some horrible code 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only nits left, great work!
fixes #1800
Currently, this only suppresses indentation for descendants of
<-
-triggered indents and only if these descendants areI'm not 100% sure this fixes all cases, but I added a more complex test case to ensure it works as intended.
Let me know if you can think of other test cases that should be included.
Also, let me know if the exception should apply to other assignment-like operators, such as EQ_ASSIGN, EQ_SUB, EQ_FORMALS, ...
One case where we probably still have a false-positive is within
lapply()
and friends. That seems hard if not impossible to fix: