-
Notifications
You must be signed in to change notification settings - Fork 73
styling with styler #170
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
styling with styler #170
Conversation
special_token, | ||
"LEFT_ASSIGN", | ||
"'$'" | ||
)) { |
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.
@krlmlr desired?
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 to me.
nrow(pd_nested) > 3 && | ||
pd_nested$lag_newlines[first_non_comment_after_call] == 0) { | ||
nrow(pd_nested) > 3 && | ||
pd_nested$lag_newlines[first_non_comment_after_call] == 0) { |
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.
Desired?
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.
@@ -58,7 +58,7 @@ update_indention_ref_fun_call <- function(pd_nested) { | |||
#' } | |||
update_indention_ref_fun_dec <- function(pd_nested) { | |||
if (pd_nested$token[1] == "FUNCTION" && | |||
nrow(pd_nested) > 3) { | |||
nrow(pd_nested) > 3) { | |||
seq <- 3:(nrow(pd_nested) - 1) |
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.
Again.
pd$lag_newlines[setdiff(3, exception_pos)] <- 1L | ||
pd | ||
} | ||
if (!is_function_call(pd)) return(pd) |
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.
Indention desired if function()
is on new line?
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.
See line 66.
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.
Not really, but we can postpone. For now, maybe move function
one line up?
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.
the problem is that the function name is so long that it does not all fit on one line...
R/serialized_tests.R
Outdated
# transformer functions | ||
filler = create_filler, | ||
transformers <- list( # transformer functions | ||
filler = create_filler, |
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.
moves comment up?! Probably undesired.
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.
Fixed that in some branch, is a minor thing.
R/style_guides.R
Outdated
@@ -156,8 +156,7 @@ create_style_guide <- function(filler = create_filler, | |||
token = NULL, | |||
indention = NULL, | |||
use_raw_indention = FALSE) { | |||
lst( | |||
# transformer functions | |||
lst( # transformer functions |
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.
Again, comment was moved up.
R/token.R
Outdated
"-", "math", "'-'", | ||
"*", "math", "'*'", | ||
"/", "math", "'/'", | ||
"^", "math", "'^'" | ||
) |
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.
will revert that.
"complete styling via top level api is correct", | ||
"(round, curly, spacing)" | ||
), { | ||
expect_warning(test_collection( |
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.
Not sure about that.
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.
Put the description on one line, make it shorter if necessary ;-)
Otherwise, the correct styling would be:
test_that(
paste(
...
),
{
...
}
)
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.
Reference: #125 (comment).
NA | ||
) | ||
} | ||
) |
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 looks strange.
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.
@krlmlr would you agree that there should be no line break if the token before )
is }
?
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.
I think that would comply with section 2.4, although function calls are not explicitly mentioned there.
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.
Fixed that in some branch, is a minor thing.
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.
This looks correct, except the {
should be on its own line.
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.
Reference: #125 (comment).
Codecov Report
@@ Coverage Diff @@
## master #170 +/- ##
==========================================
+ Coverage 93.85% 93.89% +0.04%
==========================================
Files 19 19
Lines 748 786 +38
==========================================
+ Hits 702 738 +36
- Misses 46 48 +2
Continue to review full report at Codecov.
|
manually restoring line breaks and and styling afterwards (lines not broken automatically anymore).
special_token, | ||
"LEFT_ASSIGN", | ||
"'$'" | ||
)) { |
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 to me.
nrow(pd_nested) > 3 && | ||
pd_nested$lag_newlines[first_non_comment_after_call] == 0) { | ||
nrow(pd_nested) > 3 && | ||
pd_nested$lag_newlines[first_non_comment_after_call] == 0) { |
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.
pd$lag_newlines[setdiff(3, exception_pos)] <- 1L | ||
pd | ||
} | ||
if (!is_function_call(pd)) return(pd) |
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.
Not really, but we can postpone. For now, maybe move function
one line up?
"complete styling via top level api is correct", | ||
"(round, curly, spacing)" | ||
), { | ||
expect_warning(test_collection( |
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.
Put the description on one line, make it shorter if necessary ;-)
Otherwise, the correct styling would be:
test_that(
paste(
...
),
{
...
}
)
NA | ||
) | ||
} | ||
) |
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.
This looks correct, except the {
should be on its own line.
Note that I have used
style_dir("R")
andstyle_dir("tests/testthat", recursive = FALSE)
to avoid stylingin.R
files. 😄