Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix related to the issue 746: not tested yet! #769

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ problem.name.MissReferenceProblem = Missing reference return value in assignment
problem.messagePattern.MissReferenceProblem = Assignment operators should return by reference
problem.description.MissReferenceProblem = This rule will flag assignment operators not returning by reference

checker.name.BlacklistChecker = Function or method in blacklist checker
problem.name.BlacklistProblem = Function or method is blacklisted
problem.messagePattern.BlacklistProblem = Function or method ''{0}'' is blacklisted
problem.description.BlacklistProblem = This rule will flag the use of functions or methods in blacklist
checker.name.ForbiddenlistChecker = Function or method in forbiddenlist checker
problem.name.ForbiddenlistProblem = Function or method is listed as forbidden
problem.messagePattern.ForbiddenlistProblem = Function or method ''{0}'' is listed as forbidden
problem.description.ForbiddenlistProblem = This rule will flag the use of functions or methods in forbiddenlist

checker.name.VariablesChecker = Variable checker
problem.name.StaticVariableInHeaderProblem = Static variable in header file
Expand Down
14 changes: 7 additions & 7 deletions codan/org.eclipse.cdt.codan.checkers/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -609,18 +609,18 @@
</problem>
</checker>
<checker
class="org.eclipse.cdt.codan.internal.checkers.BlacklistChecker"
id="org.eclipse.cdt.codan.internal.checkers.BlacklistChecker"
name="%checker.name.BlacklistChecker">
class="org.eclipse.cdt.codan.internal.checkers.ForbiddenlistChecker"
id="org.eclipse.cdt.codan.internal.checkers.ForbiddenlistChecker"
name="%checker.name.ForbiddenlistChecker">
<problem
category="org.eclipse.cdt.codan.core.categories.CodeStyle"
defaultEnabled="false"
defaultSeverity="Warning"
description="%problem.description.BlacklistProblem"
id="org.eclipse.cdt.codan.internal.checkers.BlacklistProblem"
description="%problem.description.ForbiddenlistProblem"
id="org.eclipse.cdt.codan.internal.checkers.ForbiddenlistProblem"
markerType="org.eclipse.cdt.codan.core.codanProblem"
messagePattern="%problem.messagePattern.BlacklistProblem"
name="%problem.name.BlacklistProblem">
messagePattern="%problem.messagePattern.ForbiddenlistProblem"
name="%problem.name.ForbiddenlistProblem">
</problem>
</checker>
<checker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class CheckersMessages extends NLS {
public static String SuspiciousSemicolonChecker_ParamElse;
public static String ProblemBindingChecker_Candidates;
public static String SwitchCaseChecker_ParameterDefaultAllEnums;
public static String BlacklistChecker_list;
public static String BlacklistChecker_list_item;
public static String ForbiddenlistChecker_list;
public static String ForbiddenlistChecker_list_item;
public static String MagicNumberChecker_ParameterArray;
public static String MagicNumberChecker_ParameterOperatorParen;
public static String UnusedSymbolInFileScopeChecker_CharacterSequence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ MagicNumberChecker_ParameterOperatorParen=Check literals in calls of class opera
NoDiscardChecker_ParameterMacro=Report problem in statements that come from macro expansion
SwitchCaseChecker_ParameterDefaultAllEnums=Mark even switches with complete enum items

BlacklistChecker_list=List of methods/functions to be checked
BlacklistChecker_list_item=Fully qualified method name or function name
ForbiddenlistChecker_list=List of methods/functions to be checked
ForbiddenlistChecker_list_item=Fully qualified method name or function name

ShallowCopyChecker_OnlyNew=Check only classes using operator 'new' in constructor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;

public class BlacklistChecker extends AbstractIndexAstChecker {
public static final String ERR_ID = "org.eclipse.cdt.codan.internal.checkers.BlacklistProblem"; //$NON-NLS-1$
public static final String PARAM_BLACKLIST = "blacklist"; //$NON-NLS-1$
public class ForbiddenlistChecker extends AbstractIndexAstChecker {
public static final String ERR_ID = "org.eclipse.cdt.codan.internal.checkers.ForbiddenlistProblem"; //$NON-NLS-1$
public static final String PARAM_FORBIDDENLIST = "forbiddenlist"; //$NON-NLS-1$

@Override
public void processAst(IASTTranslationUnit ast) {
Object[] list = (Object[]) getPreference(getProblemById(ERR_ID, getFile()), PARAM_BLACKLIST);
Object[] list = (Object[]) getPreference(getProblemById(ERR_ID, getFile()), PARAM_FORBIDDENLIST);
if (list == null || list.length == 0)
return;
Arrays.sort(list);
Expand Down Expand Up @@ -67,7 +67,7 @@ private String getBindingQualifiedName(IBinding binding) {
@Override
public void initPreferences(IProblemWorkingCopy problem) {
super.initPreferences(problem);
addListPreference(problem, PARAM_BLACKLIST, CheckersMessages.BlacklistChecker_list,
CheckersMessages.BlacklistChecker_list_item);
addListPreference(problem, PARAM_FORBIDDENLIST, CheckersMessages.ForbiddenlistChecker_list,
CheckersMessages.ForbiddenlistChecker_list_item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
package org.eclipse.cdt.codan.core.internal.checkers;

import org.eclipse.cdt.codan.core.tests.CheckerTestCase;
import org.eclipse.cdt.codan.internal.checkers.BlacklistChecker;
import org.eclipse.cdt.codan.internal.checkers.ForbiddenlistChecker;

/**
* Test for {@link BlacklistChecker} class
* Test for {@link ForbiddenlistChecker} class
*/
public class BlacklistCheckerTest extends CheckerTestCase {
public class ForbiddenlistCheckerTest extends CheckerTestCase {

public static final String ERR_ID = BlacklistChecker.ERR_ID;
public static final String ERR_ID = ForbiddenlistChecker.ERR_ID;

@Override
public void setUp() throws Exception {
Expand All @@ -38,7 +38,7 @@ public boolean isCpp() {
// int * p = (int*)dontcall());
//}
public void testWithFunctionCall() throws Exception {
setPreferenceValue(BlacklistChecker.ERR_ID, BlacklistChecker.PARAM_BLACKLIST, new String[] { "dontcall" });
setPreferenceValue(ForbiddenlistChecker.ERR_ID, ForbiddenlistChecker.PARAM_FORBIDDENLIST, new String[] { "dontcall" });
loadCodeAndRun(getAboveComment());
checkErrorLine(1, ERR_ID);
checkErrorLine(5, ERR_ID);
Expand All @@ -51,7 +51,7 @@ public void testWithFunctionCall() throws Exception {
// void* (*ptr)() = dontcall;
//}
public void testWithFunctionPtr() throws Exception {
setPreferenceValue(BlacklistChecker.ERR_ID, BlacklistChecker.PARAM_BLACKLIST, new String[] { "dontcall" });
setPreferenceValue(ForbiddenlistChecker.ERR_ID, ForbiddenlistChecker.PARAM_FORBIDDENLIST, new String[] { "dontcall" });
loadCodeAndRun(getAboveComment());
checkErrorLine(1, ERR_ID);
checkErrorLine(5, ERR_ID);
Expand All @@ -68,7 +68,7 @@ public void testWithFunctionPtr() throws Exception {
// f.dontcall();
//}
public void testWithMethod() throws Exception {
setPreferenceValue(BlacklistChecker.ERR_ID, BlacklistChecker.PARAM_BLACKLIST, new String[] { "Foo::dontcall" });
setPreferenceValue(ForbiddenlistChecker.ERR_ID, ForbiddenlistChecker.PARAM_FORBIDDENLIST, new String[] { "Foo::dontcall" });
loadCodeAndRun(getAboveComment());
checkErrorLine(3, ERR_ID);
checkErrorLine(9, ERR_ID);
Expand Down
Loading