Skip to content
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-empty-class-body auto-correction leaves spacing when file ends with {} #109

Closed
thauk-copperleaf opened this issue Nov 23, 2017 · 8 comments

Comments

@thauk-copperleaf
Copy link

I am trying to write a test case for a bug I found, but I'm on Windows 7, and I've just noticed that there's a hardcoded expectations in the unit tests that the line terminators are \n. Is this already known & expected?

@thauk-copperleaf
Copy link
Author

The bug in question is that the NoEmptyClassBodyRule does not remove whitespace between the declaration and the block if the block is not terminated by a newline.

i.e. if you have:
"fun main() {\n}"
you expect the rule to format this to:
"fun main()"
but you get:
"fun main() "

Which means if you ran ktlint again, NoTrailingSpacesRuleTest would cause it to fail.

shyiko added a commit that referenced this issue Nov 23, 2017
@shyiko
Copy link
Collaborator

shyiko commented Nov 23, 2017

Thank you, @thauk-copperleaf. This particular issue is fixed (see commit above).
As for line terminators, ktlint is forcing \n regardless of the OS. CI on Windows will be taken care of in #110.

@shyiko shyiko changed the title Tests do not run on Windows no-empty-class-body auto-correction leaves spacing when file ends with {} Nov 23, 2017
@shyiko shyiko closed this as completed Nov 23, 2017
@thauk-copperleaf
Copy link
Author

@shyiko I had the same code change pending but I didn't want to submit a PR without a unit test :) Thanks for the fix :)

@thauk-copperleaf
Copy link
Author

@shyiko As for the forcing \n, it wasn't working on my system. I double-checked that I was at the same commit as the last Travis build, and I am, but the tests don't pass (at least NoEmptyClassBodyRuleTest) on Windows 7 :(

@shyiko
Copy link
Collaborator

shyiko commented Nov 23, 2017

@thauk-copperleaf tests on Windows are now green (https://ci.appveyor.com/project/shyiko/ktlint/build/master.3) (#110 resolved).

@thauk-copperleaf
Copy link
Author

@shyiko Thanks for the quick replies! BTW, any plans for a "missing newline at end of file" rule? Many tools warn/error about that (including git).

@shyiko
Copy link
Collaborator

shyiko commented Nov 23, 2017

@thauk-copperleaf it's supported but not enabled by default (#103). We plan to change this in the next release.

@thauk-copperleaf
Copy link
Author

@shyiko Excellent! Thanks!

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

No branches or pull requests

2 participants