@Before
  public void setUp() {
    final ConfigRuntime conf = new ConfigRuntime();
    final PluginInfoRule pluginRule = new PluginInfoRule();
    pluginRule.setName("FunctionHintChecker");
    conf.getRules().add(pluginRule);
    final PluginMessage pluginMessage = new PluginMessage("FUNCTION_HINT_MISSING");
    pluginMessage.setSeverity("WARNING");
    pluginMessage.setMessageText("Function ${variable} is missing a hint.");
    pluginRule.getMessages().add(pluginMessage);

    cfBugs = new CFLint(conf, new FunctionHintChecker());
  }
 @Before
 public void setUp() {
   final ConfigRuntime conf = new ConfigRuntime();
   final PluginInfoRule pluginRule = new PluginInfoRule();
   pluginRule.setName("LiteralChecker");
   conf.getRules().add(pluginRule);
   final PluginMessage pluginMessage = new PluginMessage("GLOBAL_LITERAL_VALUE_USED_TOO_OFTEN");
   pluginMessage.setSeverity("WARNING");
   LiteralChecker checker = new LiteralChecker();
   checker.setParameter("maximum", "3");
   checker.setParameter("maxWarnings", "2");
   checker.setParameter("scope", "global");
   cfBugs = new CFLint(conf, checker);
 }
Пример #3
0
 public static CFLintScanner loadPlugin(final PluginInfoRule ruleInfo) {
   final String shortClassName =
       ruleInfo.getClassName() != null && ruleInfo.getClassName().trim().length() > 0
           ? ruleInfo.getClassName()
           : ruleInfo.getName();
   final String className = PLUGIN_PACKAGE + "." + shortClassName.trim();
   try {
     final Class<?> pluginClass = Class.forName(className);
     final CFLintScanner plugin = (CFLintScanner) pluginClass.newInstance();
     for (PluginParameter param : ruleInfo.getParameters()) {
       plugin.setParameter(param.getName(), param.getValue());
     }
     ruleInfo.setPluginInstance(plugin);
     return plugin;
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }