16
16
*/
17
17
package org.sonarsource.kotlin.checks
18
18
19
+ import org.jetbrains.kotlin.analysis.api.resolution.KaFunctionCall
19
20
import org.jetbrains.kotlin.psi.KtCallExpression
20
- import org.jetbrains.kotlin.resolve.calls.util.getFirstArgumentExpression
21
- import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
22
21
import org.sonar.check.Rule
23
22
import org.sonarsource.kotlin.api.checks.CallAbstractCheck
24
23
import org.sonarsource.kotlin.api.checks.FunMatcher
24
+ import org.sonarsource.kotlin.api.checks.FunMatcherImpl
25
+ import org.sonarsource.kotlin.api.checks.getFirstArgumentExpression
25
26
import org.sonarsource.kotlin.api.checks.predictRuntimeBooleanValue
26
27
import org.sonarsource.kotlin.api.frontend.KotlinFileContext
27
28
28
29
private const val MESSAGE = " Make sure this debug feature is deactivated before delivering the code in production."
29
30
30
- @org.sonarsource.kotlin.api.frontend.K1only
31
31
@Rule(key = " S4507" )
32
32
class DebugFeatureEnabledCheck : CallAbstractCheck () {
33
33
@@ -38,8 +38,8 @@ class DebugFeatureEnabledCheck : CallAbstractCheck() {
38
38
{ withArguments(" kotlin.Boolean" ) },
39
39
)
40
40
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 ) {
43
43
kotlinFileContext.reportIssue(callExpression, MESSAGE )
44
44
}
45
45
}
0 commit comments