-
Notifications
You must be signed in to change notification settings - Fork 73
Format all test cases with air for comparison #1256
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
base: main
Are you sure you want to change the base?
Conversation
21b9133
to
c207765
Compare
@DavisVaughan and @lionel-, I just created the formatting diff for {styler} and air on {styler}'s test cases. As discussed, this might be helpful for you to identify (edge) cases you missed. There are 5.5k lines of code here to be styled
air would re-format a substantial part of it. To me, it seems larger than expected. |
This comment was marked as outdated.
This comment was marked as outdated.
This is how benchmark results would change (along with a 95% confidence interval in relative change) if c207765 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
@lorenzwalthert Thanks for doing this! It seems there is a problem though. For instance that first file c(
"x",
"z",
"cgjhg",
"thi",
"z"
)
c(
"x",
"z",
"cgjhg",
"thi",
"z"
)
c(
"x",
"y",
"z",
"m",
"n",
"o",
"p",
"c",
"d"
) Looking at |
@lionel- Is it more clear now? |
gotcha, but it still looks like the formatter wasn't applied to these |
this does not include all files since air failed for some files
c207765
to
9092498
Compare
ok @lionel- my bad, something went wrong. I think
Maybe it would be useful to say which ones in the CLI? Even the backtrace did not help:
So for all files that failed, we compared test input and styler output instead of air vs styler output before I force pushed. Since it seemed to be parallelised, I just ran |
This is how benchmark results would change (along with a 95% confidence interval in relative change) if 9092498 is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation. |
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.
Quite happy with the results overall!
tt = NULL, | ||
ayz = NULL) {} | ||
|
||
function(x = NULL, tt = NULL, ayz = NULL) { |
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 empty braces will be fixes as part of posit-dev/air#186
call({{ | ||
# | ||
}}) | ||
call({ |
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 difference is expected.
#' ano("\\.", further = X) | ||
NULL | ||
|
||
"single quotes with | ||
embedded and \n not embedded line breaks" | ||
'single quotes with |
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 opened posit-dev/air#231 for this.
print(value) | ||
} | ||
|
||
if (value > 0) print(value) |
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.
Although we recommend side effects to be on their own line, we currently don't force it.
I wonder if we should force multi-line if the if
is not assigned or part of a larger call though, since that indicates a side effect.
3 | ||
else | ||
4 | ||
if (TRUE) 3 else 4 | ||
} | ||
|
||
{ | ||
if (TRUE) { |
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 this will be fixed soon by @DavisVaughan's work on braces.
a = 2, | ||
y = 3 | ||
) | ||
switch(x, a = 2, y = 3) |
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 persistent line is only on the first argument so that's expected.
call(call( # comment | ||
3, 4 | ||
)) | ||
call( |
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 already.
####### A comment | ||
#'roxygen |
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 don't do any normalisation of comments currently. Something to think about though.
@@ -1,9 +1,9 @@ | |||
a <- b <- c <- d <- e <- f <- g <- 4 | |||
a = b = c = d = e = f = g = 4 |
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.
yep this is allowed by Air. We'll have a linter to enforce a style in a repo though. Or perhaps this should be one of the few options.
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.
Discussed in posit-dev/air#231 (comment)
style = tidyverse_style, | ||
transformers = style(...), | ||
include_roxygen_examples = TRUE) { | ||
changed <- withr::with_dir( | ||
dirname(path), | ||
changed<- withr::with_dir( |
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.
Parse error?
This is a cool thread to watch! Please notify me when it reaches a stable state (i.e. neither {styler} nor {air} will make further changes to converge to one another), it will be quite helpful. I'll also link some seemingly related threads / issues: |
This will fix the panic posit-dev/air#240, also After fixing the panic, running
The The a[[
2
]
] But overall that's pretty solid for the parser |
Sounds good. I am glad running air on our test suit helps polishing your release 😊 |
All test code was formatted with air and then written to the file where we previously stored the expected output of styler (with the helper script
inst/air/overwrite-in-test-files-with-out-files.R
). Then, Igit add tests/testthat/**/*-out.R
and committed. This PR was created for diff review only.