mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-72636 ("Log statement not guarded by log condition" inspection fails on custom logging methods with method signatures different from log.debug(String))
This commit is contained in:
+12
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2012 Bas Leijdekkers
|
||||
* Copyright 2008-2013 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -221,9 +221,17 @@ public class LogStatementGuardedByLogConditionInspection extends BaseInspection
|
||||
if (arguments.length == 0) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression firstArgument = arguments[0];
|
||||
if (!flagAllUnguarded && PsiUtil.isConstantExpression(firstArgument)) {
|
||||
return;
|
||||
if (!flagAllUnguarded) {
|
||||
boolean constant = true;
|
||||
for (PsiExpression argument : arguments) {
|
||||
if (!PsiUtil.isConstantExpression(argument)) {
|
||||
constant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (constant) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
registerMethodCallError(expression);
|
||||
}
|
||||
|
||||
+6
@@ -32,6 +32,10 @@ public class LogStatementGuardedByLogCondition {
|
||||
}
|
||||
}
|
||||
|
||||
void alternativeDebugMethodSignature(int i) {
|
||||
LOG.debug(i, "asdfasdf");
|
||||
}
|
||||
|
||||
static class Logger {
|
||||
|
||||
public Logger(String log) {
|
||||
@@ -40,6 +44,8 @@ public class LogStatementGuardedByLogCondition {
|
||||
public void debug(String s) {
|
||||
}
|
||||
|
||||
public void debug(int i, String s) {}
|
||||
|
||||
public void trace(String s) {}
|
||||
|
||||
public boolean isDebug() {
|
||||
|
||||
+7
@@ -14,4 +14,11 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Log statement not guarded by log condition</problem_class>
|
||||
<description><code>debug()</code> log statement not guarded by log condition #loc</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>LogStatementGuardedByLogCondition.java</file>
|
||||
<line>36</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Log statement not guarded by log condition</problem_class>
|
||||
<description><code>debug()</code> log statement not guarded by log condition #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
Reference in New Issue
Block a user