Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix crashing on empty #474

Merged
merged 5 commits into from
Oct 17, 2019
Merged

Fix crashing on empty #474

merged 5 commits into from
Oct 17, 2019

Conversation

MarkRyanDev
Copy link
Contributor

Fixes #305

ImportSorter no longer blows up if you give it an empty file.

Copy link
Member

@nedtwigg nedtwigg left a comment

Choose a reason for hiding this comment

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

Thanks! Your fix does a good job at the site of the stacktrace, but it seems easier to just say at the beginning of the function if (input.isEmpty()) { return input; }. That way all the code below that can take as a precondition "this string has length > 0". That's more robust than having to check for it at every point.

Also, update your changelog entry so that it points to this PR.

Thanks for the PR!

@nedtwigg nedtwigg merged commit 61a7277 into diffplug:master Oct 17, 2019
@nedtwigg
Copy link
Member

Thanks again!

@nedtwigg
Copy link
Member

Released in x.26.0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StringIndexOutOfBoundsException for empty Groovy file when performing importOrder
2 participants