Skip to content

Don't assume file is 50 characters long#699

Merged
nedtwigg merged 5 commits intodiffplug:mainfrom
skevy:patch-1
Sep 18, 2020
Merged

Don't assume file is 50 characters long#699
nedtwigg merged 5 commits intodiffplug:mainfrom
skevy:patch-1

Conversation

@skevy
Copy link
Copy Markdown
Contributor

@skevy skevy commented Sep 18, 2020

When upgrading to Spotless 5.5.1, I was receiving this error when trying to format a small GraphQL file in my codebase:

String index out of range: 50
java.lang.StringIndexOutOfBoundsException: String index out of range: 50
        at java.lang.String.substring(String.java:1963)
        at com.diffplug.spotless.npm.PrettierFormatterStep$PrettierFilePathPassingFormatterFunc.applyWithFile(PrettierFormatterStep.java:116)String index out of range: 50
java.lang.StringIndexOutOfBoundsException: String index out of range: 50

It seems to be due to this log line that assumes that any content being passed to Prettier is at least 50 characters long.

I changed this logic to instead print up to 50 characters of the string.

@nedtwigg
Copy link
Copy Markdown
Member

Good call, thanks very much.

@nedtwigg nedtwigg merged commit 52c79e7 into diffplug:main Sep 18, 2020
@nedtwigg
Copy link
Copy Markdown
Member

Published in plugin-gradle 5.5.2 and plugin-maven 2.4.1.

@skevy skevy deleted the patch-1 branch September 19, 2020 02:16
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