Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Conversation

lorenzwalthert
Copy link
Collaborator

@lorenzwalthert lorenzwalthert commented Aug 30, 2017

Note that I have used style_dir("R") and style_dir("tests/testthat", recursive = FALSE) to avoid styling in.R files. 😄

special_token,
"LEFT_ASSIGN",
"'$'"
)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krlmlr desired?

Copy link
Member

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) {
Copy link
Collaborator Author

@lorenzwalthert lorenzwalthert Aug 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Desired?

Copy link
Member

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)
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See line 66.

Copy link
Member

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?

Copy link
Collaborator Author

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...

# transformer functions
filler = create_filler,
transformers <- list( # transformer functions
filler = create_filler,
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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
Copy link
Collaborator Author

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", "'^'"
)
Copy link
Collaborator Author

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(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about that.

Copy link
Member

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(
    ...
  ),
  {
    ...
  }
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference: #125 (comment).

NA
)
}
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks strange.

Copy link
Collaborator Author

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 }?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference: #125 (comment).

@lorenzwalthert lorenzwalthert requested a review from krlmlr August 30, 2017 14:56
@codecov
Copy link

codecov bot commented Aug 30, 2017

Codecov Report

Merging #170 into master will increase coverage by 0.04%.
The diff coverage is 95.03%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
R/ws.R 88.88% <ø> (ø) ⬆️
R/parsed.R 93.75% <ø> (ø) ⬆️
R/modify_pd.R 92.68% <ø> (ø) ⬆️
R/serialized_tests.R 100% <100%> (ø) ⬆️
R/unindent.R 96.42% <100%> (+0.27%) ⬆️
R/relevel.R 100% <100%> (ø) ⬆️
R/nested.R 98.38% <100%> (+0.11%) ⬆️
R/visit.R 100% <100%> (ø) ⬆️
R/transform.R 96.72% <100%> (+0.11%) ⬆️
R/rules-other.R 100% <100%> (ø) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ad76a7...a82e2a0. Read the comment docs.

manually restoring line breaks and
and styling afterwards (lines not broken automatically anymore).
special_token,
"LEFT_ASSIGN",
"'$'"
)) {
Copy link
Member

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) {
Copy link
Member

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)
Copy link
Member

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(
Copy link
Member

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
)
}
)
Copy link
Member

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.

@lorenzwalthert lorenzwalthert deleted the tidyup branch September 17, 2017 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants