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

Always fail task on Ktlint crash #229

Closed
tasomaniac opened this issue Apr 23, 2019 · 8 comments
Closed

Always fail task on Ktlint crash #229

tasomaniac opened this issue Apr 23, 2019 · 8 comments

Comments

@tasomaniac
Copy link
Contributor

tasomaniac commented Apr 23, 2019

I've noticed that while running any of the KtlintCheck tasks, if running ktlint executable fails, the task is not marked as failure.

Here is an example with incompatibility with Kotlin 1.3.30


> Task :project:ktlintMainSourceSetCheck
Exception in thread "main" java.lang.NoSuchFieldError: PROPERTY_DELEGATE
	at com.github.shyiko.ktlint.core.ast.ElementType.<clinit>(ElementType.kt:33)
	at com.github.shyiko.ktlint.ruleset.standard.ChainWrappingRule.<init>(ChainWrappingRule.kt:36)
	at com.github.shyiko.ktlint.ruleset.standard.StandardRuleSetProvider.get(StandardRuleSetProvider.kt:12)
	at com.github.shyiko.ktlint.Main.main(Main.kt:310)

The exception is recorded, ktlint actually does not run, but the task is marked as success.

@tasomaniac tasomaniac changed the title Any error while executing Ktlint is ignored Errors while executing Ktlint is ignored Apr 23, 2019
@tasomaniac tasomaniac changed the title Errors while executing Ktlint is ignored Errors while executing Ktlint are ignored Apr 23, 2019
@Tapchicoma Tapchicoma added the bug label Apr 23, 2019
@Tapchicoma
Copy link
Collaborator

@tasomaniac could it happen that you have enabled ignoreFailuers in ktlint-gradle extension?

val ignoreFailures: Property<Boolean> = objectFactory.property { set(false) }

@tasomaniac
Copy link
Contributor Author

Hmm actually I did and then I have another task of myself that evaluates the xml reports.

I wonder if there is a way to differentiate failures and errors though. I would like to ignore failures resulting from a successful run of the ktlint task. But not for errors that causes ktlint task to crash and never run.

I'm not sure if this is technically possible but would be good to differentiate these two scenarios.

@Tapchicoma Tapchicoma changed the title Errors while executing Ktlint are ignored Always fail task on Ktlint crash Apr 24, 2019
@Tapchicoma
Copy link
Collaborator

I doubt that it will be possible, but will try to investigate.

@tasomaniac
Copy link
Contributor Author

I can also have a look if you agree that it's a good idea

@Tapchicoma
Copy link
Collaborator

Feel free to do it. I think it is a good idea to fail the build on ktlint crash when ignoreFailures is enabled.

@JLLeitschuh
Copy link
Owner

Is this still an issue? Has it been resolved?

@tasomaniac
Copy link
Contributor Author

I believe this is technically still an issue. But not sure how important it is.

One way to solve this would be to create an xml report and include the execution issues as errors there. I think Android Lint does that.

@JLLeitschuh
Copy link
Owner

Are you able to create a demo or, even better, a unit test that demonstrates this issue?

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

No branches or pull requests

3 participants