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

Experimental AnnotationRule crashes on format #625

Closed
bethcutler opened this issue Oct 17, 2019 · 2 comments · Fixed by #628
Closed

Experimental AnnotationRule crashes on format #625

bethcutler opened this issue Oct 17, 2019 · 2 comments · Fixed by #628
Labels

Comments

@bethcutler
Copy link
Contributor

Sample code:

class Foo @Inject internal constructor() {
}

Trying to format this code with the experimental AnnotationRule enabled causes this crash:

com.pinterest.ktlint.core.RuleExecutionException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:384)
	at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:41)
	at com.pinterest.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:279)
	at com.pinterest.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:41)
	at com.pinterest.ktlint.core.KtLint.visit(KtLint.kt:536)
	at com.pinterest.ktlint.core.KtLint.visit(KtLint.kt:537)
	at com.pinterest.ktlint.core.KtLint.visit(KtLint.kt:537)
	at com.pinterest.ktlint.core.KtLint.access$visit(KtLint.kt:41)
	at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:278)
	at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:41)
	at com.pinterest.ktlint.core.KtLint.format(KtLint.kt:367)
	at com.pinterest.ktlint.internal.FileUtilsKt.formatFile(FileUtils.kt:79)
	at com.pinterest.ktlint.KtlintCommandLine$run$1.invoke(Main.kt:240)
	at com.pinterest.ktlint.KtlintCommandLine$run$4$1.call(Main.kt:306)
	at com.pinterest.ktlint.KtlintCommandLine$run$4$1.call(Main.kt:115)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(String.java:1929)
	at com.pinterest.ktlint.ruleset.experimental.AnnotationRule.visit(AnnotationRule.kt:97)
	at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:372)
	... 18 more
@Tapchicoma Tapchicoma added the bug label Oct 19, 2019
@yukukotani
Copy link
Contributor

Cannot reproduce in latest master (fc5f03d).

@yukukotani
Copy link
Contributor

Oh sorry, I succeed to reproduce with format, not only check.

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

Successfully merging a pull request may close this issue.

3 participants