-
Notifications
You must be signed in to change notification settings - Fork 39
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
Avoid inserting blank lines in ErrorProneTestHelperSourceFormat auto-fix #474
Comments
Thanks for the feedback @msridhar!
I suppose we could introduce a flag that post-processes the check's suggestions by omitting empty strings. The resultant formatting would then not longer be fully GJF compliant, though.
Yeah, indeed we've been relying on auto-fixes instead. For this we use Off the top of my head the modification to the fork aren't relevant if one wishes to apply the suggestions of a single Anyway, while I'd have to take look closer for the details, I think we'd not be opposed to an optional (disabled-by-default) flag that omits empty lines. Let me know if you'd like to go that route for NullAway; then I'll see what we can do. NB: while we plan to support JDK 11 for the foreseeable future, ideally we introduce conditional text block support to this check, as that works quite well with IDEA's language injection feature, enabling one to write Java-inside-Java. We have a WIP PR for that: #198. |
True. My issue is that I think the extra empty strings make the test code less readable, in addition to making them harder to write by hand.
Cool! Yeah I think we could rig up a similar auto-fix config for our Gradle build. I think we would need something like this, in fact, along with good instructions, as fixing these errors by hand would be pretty annoying (particularly for new contributors). Depending on the overhead imposed we may even want to run in a config where we auto-fix these issues periodically rather than enabling the check by default.
IMO it would be good to support this feature, just in terms of test code readability. I think we would likely want the flag for NullAway usage (and it's fine for it to be off by default). But, as you can see above, I haven't quite decided what exactly our workflow would be for NullAway and how exactly we would adopt this check. So it's completely fine if adding such a flag is low priority.
That would be really cool! Unfortunately we will also be supporting JDK 11 for the foreseeable future so wouldn't be able to take advantage anytime soon. |
Ack! Then I'll look into adding this feature in the near future. 👍 |
Hey @msridhar, on your branch msridhar/NullAway@7c8ac63#diff-d8162adf8ce392acc05a12713ac761cde51b50b4250a3d408cb04e66ee8ec85aR78 I see some checks are disabled. I can imagine most of these checks are quite opinionated and therefore may be less useful. However, I'm curious about the reasons for disabling the checks |
@rickie my primary purpose on that branch was to test the |
That makes sense. Good to know, thanks 😄! |
Thanks for the great package of checks! I tried to apply ErrorProneTestHelperSourceFormat and its autofixes to our tests in NullAway, and saw that blank lines get inserted as
""
. E.g.:msridhar/NullAway@7c8ac63#diff-409faf90d91de636986e6f96aabde20a120b5442cbc3a32af4db4ca837915fceR21
Would it be possible for the check to not require these blank lines, and for the auto-fix not to insert them? Alternately, could you describe your workflow for writing tests such that the developer does not need to manually write these lines? Do you have a good way to write these tests without manually writing and indenting source lines enclosed in quotes? Thanks so much!
The text was updated successfully, but these errors were encountered: