-
Notifications
You must be signed in to change notification settings - Fork 72
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
No line break after switch and friends #152
Conversation
620e26c
to
319a165
Compare
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.
Looks good. Could you please update the rlang pull request?
Sure. Should I submit an issue to the tidyverse style guide? |
Yes, please. |
Codecov Report
@@ Coverage Diff @@
## master #152 +/- ##
==========================================
+ Coverage 85.86% 85.95% +0.09%
==========================================
Files 19 19
Lines 778 783 +5
==========================================
+ Hits 668 673 +5
Misses 110 110
Continue to review full report at Codecov.
|
Do you think the text tokens be arguments in |
@@ -75,7 +75,8 @@ tidyverse_style <- function(scope = "tokens", | |||
add_line_break_before_curly_closing, | |||
partial( | |||
set_line_break_after_opening_if_call_is_multi_line, | |||
except_token = "COMMENT" | |||
except_token_after = "COMMENT", | |||
except_text_before = c("switch", "ifelse", "if_else") |
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.
Maybe expose an argument to tidyverse_style()
that allows adding more exceptions?
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.
(Basically answering "yes" to your earlier question, if I understood correctly.)
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.
Ok, what how does that relate to tidyverse/style#39? It seems to be about named arguments according to the answer there, and not to function names anyways.
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.
Let's merge this the way it is now and discuss rules that involve named/unnamed arguments separately.
@@ -75,7 +75,8 @@ tidyverse_style <- function(scope = "tokens", | |||
add_line_break_before_curly_closing, | |||
partial( | |||
set_line_break_after_opening_if_call_is_multi_line, | |||
except_token = "COMMENT" | |||
except_token_after = "COMMENT", |
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.
Side note: I'm not sure about the scope
argument to this function, maybe scope
should be an argument of the top-level style_()
functions? The default values of the arguments to this function here are useful, we can easily change that later.
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.
Well you can do style_text("a <- 3", scope = "tokens")
, so it is a top-level argument trough ...
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.
We can keep it for now and decide later.
- Vignette on customizing styler (#145). - No line break after `switch()` and friends (#152). - Remove flat relicts completely (#151). - Don't reindent function calls and break line correctly for multi-line calls (#149). - Set space between "=" and "," (#150). - Make R CMD Check perfect (#148). - Adding tests for exception handling with invalid parse data (#139). - Fix indention by checking for all potential triggers (#142). - Fix un-indention (#135). - Support wide characters (#130). - No spaces around :, :: and :::. - Redesigning the API (#123). - Solve eq_sub indention in general (#125). - Minor refactorings. - Re-indent token-dependent (#119). - Supporting more indention patterns. - Allow raw indention. - Definitively fixing eol issue with comments. - Infrastructure. - Flattening out the parse table. - New rule: no space after ! -> !!! for tidyeval. - Fix spacing around '{'. - Don't drop tokens! Fixes #101. - EOL spaces in empty comments (and in general) (#98). - mal-indention in conditional statement due to wrong specification of indent_without_paren) (#95). - Complicated indentions based on arithmetic and special operators (#96). - indention interaction on with assignment operator and other operators (#97).
As requested in krlmlr/rlang#1 (comment), it is now possible to not break the line in function calls where the text of the function is in
except_text_before
. I.e.Will not be turned into
Since there is no such rule in the tidyverse style guide yet, I suggest opening an issue or PR before merging this.
Also, I am not sure whether the names of the functions should be an argument to
tidyverse_style()
. For now, they are not.case_when()
might also be such a function that should be treated as an exception.