1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 11:15:38 +02:00

Added arguments, description and externalized strings

This commit is contained in:
Alena Laskavaia 2010-05-24 21:54:19 +00:00
parent f4f2bfd6ee
commit 6e50087a2b
6 changed files with 12 additions and 8 deletions

View file

@ -13,7 +13,7 @@
defaultSeverity="Warning" defaultSeverity="Warning"
description="Finds statements like 'if (a=b)'" description="Finds statements like 'if (a=b)'"
id="org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem" id="org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem"
messagePattern="Possible assignment in condition" messagePattern="Possible assignment in condition ''{0}''"
name="Assignment in condition"> name="Assignment in condition">
</problem> </problem>
@ -39,6 +39,7 @@
<problem <problem
category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems" category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
defaultSeverity="Warning" defaultSeverity="Warning"
description="If destructor is not declared virtual - destructor of derived class would not be called."
id="org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem" id="org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem"
messagePattern="Class &apos;&apos;{0}&apos;&apos; has virtual method &apos;&apos;{1}&apos;&apos; but non-virtual destructor &apos;&apos;{2}&apos;&apos;" messagePattern="Class &apos;&apos;{0}&apos;&apos; has virtual method &apos;&apos;{1}&apos;&apos; but non-virtual destructor &apos;&apos;{2}&apos;&apos;"
name="Class has a virtual method and non-virtual destructor"> name="Class has a virtual method and non-virtual destructor">
@ -55,7 +56,7 @@
description="Catching by reference is recommended by C++ experts, &quot;Throw by value, catch by reference&quot;. For one thing, this avoids copying and potentially slicing the exception." description="Catching by reference is recommended by C++ experts, &quot;Throw by value, catch by reference&quot;. For one thing, this avoids copying and potentially slicing the exception."
id="org.eclipse.cdt.codan.internal.checkers.CatchByReference" id="org.eclipse.cdt.codan.internal.checkers.CatchByReference"
name="Catching by reference is recommended" name="Catching by reference is recommended"
messagePattern="Catching by reference is recommended for non-basic types"> messagePattern="Catching by reference is recommended &apos;&apos;{0}&apos;&apos;">
</problem> </problem>
</checker> </checker>
<checker <checker
@ -65,8 +66,9 @@
<problem <problem
category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems" category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
defaultSeverity="Warning" defaultSeverity="Warning"
description="This checker finds problems related to either lack of understanding precedence of operators or misspelling of operators in expression. For example (!a&lt;10) or (a &amp;&amp; b &amp; c)"
id="org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem" id="org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem"
messagePattern="Suggested parenthesis around expression" messagePattern="Suggested parenthesis around expression &apos;&apos;{0}&apos;&apos;"
name="Suggested parenthesis around expression"> name="Suggested parenthesis around expression">
</problem> </problem>
</checker> </checker>

View file

@ -35,7 +35,7 @@ public class AssignmentInConditionChecker extends AbstractIndexAstChecker {
public int visit(IASTExpression expression) { public int visit(IASTExpression expression) {
if (isAssignmentExpression(expression) if (isAssignmentExpression(expression)
&& isUsedAsCondition(expression)) { && isUsedAsCondition(expression)) {
reportProblem(ER_ID, expression); reportProblem(ER_ID, expression, expression.getRawSignature());
} }
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }

View file

@ -75,7 +75,7 @@ public class CatchByReference extends AbstractIndexAstChecker {
|| typeName instanceof IPointerType || typeName instanceof IPointerType
|| typeName == null) || typeName == null)
continue; continue;
reportProblem(ER_ID, decl); reportProblem(ER_ID, decl, decl.getRawSignature());
} }
} }
} }

View file

@ -22,6 +22,7 @@ public class CheckersMessages extends NLS {
public static String StatementHasNoEffectChecker_ParameterExceptions; public static String StatementHasNoEffectChecker_ParameterExceptions;
public static String StatementHasNoEffectChecker_ParameterExceptionsItem; public static String StatementHasNoEffectChecker_ParameterExceptionsItem;
public static String StatementHasNoEffectChecker_ParameterMacro; public static String StatementHasNoEffectChecker_ParameterMacro;
public static String SuggestedParenthesisChecker_SuggestParanthesesAroundNot;
static { static {
// initialize resource bundle // initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, CheckersMessages.class); NLS.initializeMessages(BUNDLE_NAME, CheckersMessages.class);

View file

@ -56,14 +56,14 @@ public class SuggestedParenthesisChecker extends AbstractIndexAstChecker {
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
if (precedence == 2) { // unary not if (precedence == 2) { // unary not
if (isParamNot() && isUsedAsOperand(expression)) { if (isParamNot() && isUsedAsOperand(expression)) {
reportProblem(ER_ID, expression); reportProblem(ER_ID, expression, expression.getRawSignature());
return PROCESS_SKIP; return PROCESS_SKIP;
} }
} else if (precedence >= 0) { } else if (precedence >= 0) {
int pp = getPrecedence(parentExpr); int pp = getPrecedence(parentExpr);
if (pp == -1 || pp == precedence) if (pp == -1 || pp == precedence)
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
reportProblem(ER_ID, expression); reportProblem(ER_ID, expression, expression.getRawSignature());
} }
} }
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
@ -136,6 +136,6 @@ public class SuggestedParenthesisChecker extends AbstractIndexAstChecker {
public void initPreferences(IProblemWorkingCopy problem) { public void initPreferences(IProblemWorkingCopy problem) {
super.initPreferences(problem); super.initPreferences(problem);
addPreference(problem, PARAM_NOT, addPreference(problem, PARAM_NOT,
"Suggest parentesis around not operator", Boolean.FALSE); CheckersMessages.SuggestedParenthesisChecker_SuggestParanthesesAroundNot, Boolean.FALSE);
} }
} }

View file

@ -3,3 +3,4 @@ ReturnChecker_Param0=Also check functions with implicit return value
StatementHasNoEffectChecker_ParameterExceptions=Exceptions (value of the problem argument) StatementHasNoEffectChecker_ParameterExceptions=Exceptions (value of the problem argument)
StatementHasNoEffectChecker_ParameterExceptionsItem=Value of the argument StatementHasNoEffectChecker_ParameterExceptionsItem=Value of the argument
StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that comes from macro expansion StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that comes from macro expansion
SuggestedParenthesisChecker_SuggestParanthesesAroundNot=Suggest parentesis around not operator