Skip to content

Commit e0bf3a7

Browse files
leveretkaGodin
authored andcommitted
SONARKT-400 Migrate DebugFeatureEnabledCheck to kotlin-analysis-api
1 parent 771bfe5 commit e0bf3a7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sonar-kotlin-checks/src/main/java/org/sonarsource/kotlin/checks/DebugFeatureEnabledCheck.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
*/
1717
package org.sonarsource.kotlin.checks
1818

19+
import org.jetbrains.kotlin.analysis.api.resolution.KaFunctionCall
1920
import org.jetbrains.kotlin.psi.KtCallExpression
20-
import org.jetbrains.kotlin.resolve.calls.util.getFirstArgumentExpression
21-
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
2221
import org.sonar.check.Rule
2322
import org.sonarsource.kotlin.api.checks.CallAbstractCheck
2423
import org.sonarsource.kotlin.api.checks.FunMatcher
24+
import org.sonarsource.kotlin.api.checks.FunMatcherImpl
25+
import org.sonarsource.kotlin.api.checks.getFirstArgumentExpression
2526
import org.sonarsource.kotlin.api.checks.predictRuntimeBooleanValue
2627
import org.sonarsource.kotlin.api.frontend.KotlinFileContext
2728

2829
private const val MESSAGE = "Make sure this debug feature is deactivated before delivering the code in production."
2930

30-
@org.sonarsource.kotlin.api.frontend.K1only
3131
@Rule(key = "S4507")
3232
class DebugFeatureEnabledCheck : CallAbstractCheck() {
3333

@@ -38,8 +38,8 @@ class DebugFeatureEnabledCheck : CallAbstractCheck() {
3838
{ withArguments("kotlin.Boolean") },
3939
)
4040

41-
override fun visitFunctionCall(callExpression: KtCallExpression, resolvedCall: ResolvedCall<*>, kotlinFileContext: KotlinFileContext) {
42-
if (resolvedCall.getFirstArgumentExpression()?.predictRuntimeBooleanValue(kotlinFileContext.bindingContext) == true) {
41+
override fun visitFunctionCall(callExpression: KtCallExpression, resolvedCall: KaFunctionCall<*>, matchedFun: FunMatcherImpl, kotlinFileContext: KotlinFileContext) {
42+
if (resolvedCall.getFirstArgumentExpression()?.predictRuntimeBooleanValue() == true) {
4343
kotlinFileContext.reportIssue(callExpression, MESSAGE)
4444
}
4545
}

0 commit comments

Comments
 (0)