Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Using kotlin context receivers breaks check #161

Open
5V715 opened this issue Dec 1, 2022 · 6 comments
Open

Using kotlin context receivers breaks check #161

5V715 opened this issue Dec 1, 2022 · 6 comments

Comments

@5V715
Copy link

5V715 commented Dec 1, 2022

using kotlins new context receivers breaks the check with

Caused by: java.lang.IllegalStateException: Analyzing /runner/_work/xxxxx/xxx.kt led to an exception. 
The original exception message was: null
Running detekt '1.19.0' on Java '11.0.16.1+1' on OS 'Linux'
If the exception message does not help, please feel free to create an issue on our GitHub page.
	at io.gitlab.arturbosch.detekt.core.AnalyzerKt.throwIllegalStateException(Analyzer.kt:162)
	at io.gitlab.arturbosch.detekt.core.AnalyzerKt.access$throwIllegalStateException(Analyzer.kt:1)
	at io.gitlab.arturbosch.detekt.core.Analyzer.runSync(Analyzer.kt:70)
	at io.gitlab.arturbosch.detekt.core.Analyzer.run(Analyzer.kt:52)
	at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$analyze$result$1.invoke(Lifecycle.kt:45)
...
Caused by: kotlin.KotlinNullPointerException
	at com.pinterest.ktlint.ruleset.standard.IndentationRule.rearrangeBlock(IndentationRule.kt:202)
	at com.pinterest.ktlint.ruleset.standard.IndentationRule.access$rearrangeBlock(IndentationRule.kt:103)
	at com.pinterest.ktlint.ruleset.standard.IndentationRule$rearrange$1.invoke(IndentationRule.kt:172)
	at com.pinterest.ktlint.ruleset.standard.IndentationRule$rearrange$1.invoke(IndentationRule.kt:170)
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:225)
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:226)
@cortinico
Copy link
Member

Can you try your code with https://github.com/detekt/detekt and raise the issue upstream eventually?

@5V715
Copy link
Author

5V715 commented Dec 2, 2022

created a test project using detekt 1.19.0. and it appears to be working with the context keyword
https://github.com/5V715/context-recievers-sample

@5V715
Copy link
Author

5V715 commented Dec 2, 2022

looks like the ktlint that is also running with it breaks it
the way to work around it was to

@file:Suppress("Indentation")

@hsalem7
Copy link

hsalem7 commented Feb 27, 2023

Is there any other solution than the workaround @file:Suppress("Indentation")?

@akhilbv
Copy link

akhilbv commented May 12, 2023

Disabling the Indentation rules solves the issue. Add the below lines to detect configuration yaml to disable the rule.

formatting:
   active: true
   Indentation:
     active: false

Then go to project settings in sonarqube and update the Detekt yaml configuration file path.

@arturbosch
Copy link
Member

Please try https://github.com/detekt/sonar-detekt/releases/tag/2.6.0-RC1 which uses a never KtLint version.

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

No branches or pull requests

5 participants