Search in sources :

Example 1 with FunctionXChecker

use of com.cflint.plugins.core.FunctionXChecker in project CFLint by cflint.

the class TestWriteDumpChecker method setUp.

@Before
public void setUp() throws Exception {
    final CFLintConfig conf = new CFLintConfig();
    final PluginInfoRule pluginRule = new PluginInfoRule();
    pluginRule.setName("WriteDumpChecker");
    pluginRule.setClassName("FunctionXChecker");
    pluginRule.addParameter("functionName", "writedump");
    conf.getRules().add(pluginRule);
    final PluginMessage pluginMessage = new PluginMessage("AVOID_USING_WRITEDUMP");
    pluginMessage.setSeverity("INFO");
    pluginMessage.setMessageText("Avoid using the ${functionName} function in production code.");
    pluginRule.getMessages().add(pluginMessage);
    FunctionXChecker checker = new FunctionXChecker();
    checker.setParameter("functionName", "writedump");
    cfBugs = new CFLint(conf, checker);
}
Also used : CFLintConfig(com.cflint.config.CFLintConfig) PluginMessage(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage) FunctionXChecker(com.cflint.plugins.core.FunctionXChecker) PluginInfoRule(com.cflint.config.CFLintPluginInfo.PluginInfoRule) Before(org.junit.Before)

Example 2 with FunctionXChecker

use of com.cflint.plugins.core.FunctionXChecker in project CFLint by cflint.

the class TestStructNewChecker method setUp.

@Before
public void setUp() throws Exception {
    final CFLintConfig conf = new CFLintConfig();
    final PluginInfoRule pluginRule = new PluginInfoRule();
    pluginRule.setName("StructNewChecker");
    pluginRule.setClassName("FunctionXChecker");
    pluginRule.addParameter("functionName", "structnew");
    conf.getRules().add(pluginRule);
    final PluginMessage pluginMessage = new PluginMessage("AVOID_USING_STRUCTNEW");
    pluginMessage.setSeverity("INFO");
    pluginMessage.setMessageText("Avoid using the ${functionName} function. Use implict structure construction instead (= {}).");
    pluginRule.getMessages().add(pluginMessage);
    FunctionXChecker checker = new FunctionXChecker();
    checker.setParameter("functionName", "structnew");
    cfBugs = new CFLint(conf, checker);
}
Also used : CFLintConfig(com.cflint.config.CFLintConfig) PluginMessage(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage) FunctionXChecker(com.cflint.plugins.core.FunctionXChecker) PluginInfoRule(com.cflint.config.CFLintPluginInfo.PluginInfoRule) Before(org.junit.Before)

Example 3 with FunctionXChecker

use of com.cflint.plugins.core.FunctionXChecker in project CFLint by cflint.

the class TestDebugChecker method setUp.

@Before
public void setUp() throws Exception {
    final CFLintConfig conf = new CFLintConfig();
    final PluginInfoRule pluginRule = new PluginInfoRule();
    pluginRule.setName("DebugChecker");
    pluginRule.setClassName("FunctionXChecker");
    pluginRule.addParameter("functionName", "IsDebugMode");
    conf.getRules().add(pluginRule);
    final PluginMessage pluginMessage = new PluginMessage("AVOID_USING_ISDEBUGMODE");
    pluginMessage.setSeverity("WARN");
    pluginMessage.setMessageText("Avoid using the ${functionName} function in production code.");
    pluginRule.getMessages().add(pluginMessage);
    FunctionXChecker checker = new FunctionXChecker();
    checker.setParameter("functionName", "IsDebugMode");
    cfBugs = new CFLint(conf, checker);
}
Also used : CFLintConfig(com.cflint.config.CFLintConfig) PluginMessage(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage) FunctionXChecker(com.cflint.plugins.core.FunctionXChecker) PluginInfoRule(com.cflint.config.CFLintPluginInfo.PluginInfoRule) Before(org.junit.Before)

Aggregations

CFLintConfig (com.cflint.config.CFLintConfig)3 PluginInfoRule (com.cflint.config.CFLintPluginInfo.PluginInfoRule)3 PluginMessage (com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage)3 FunctionXChecker (com.cflint.plugins.core.FunctionXChecker)3 Before (org.junit.Before)3