use of com.cflint.config.CFLintPluginInfo.RuleGroup in project CFLint by cflint.
the class CFLintMain method listRuleGroups.
/**
* List the rule groups
*
* @param pluginInfo
*/
private static void listRuleGroups(CFLintPluginInfo pluginInfo) {
Map<String, PluginMessage> allCodes = new LinkedHashMap<String, PluginMessage>();
for (PluginInfoRule rule : pluginInfo.getRules()) {
for (PluginMessage msg : rule.getMessages()) {
allCodes.put(msg.getCode(), msg);
}
}
for (RuleGroup ruleGroup : pluginInfo.getRuleGroups()) {
System.out.println("Rule Group : " + ruleGroup.getName());
for (PluginMessage msg : ruleGroup.getMessages()) {
System.out.println("\t" + msg.getCode() + " : " + msg.getSeverity());
allCodes.remove(msg.getCode());
}
}
if (!allCodes.isEmpty()) {
System.out.println("Rule Group : UNASSIGNED");
for (PluginMessage msg : allCodes.values()) {
System.out.println("\t" + msg.getCode() + " : " + msg.getSeverity());
}
}
}
use of com.cflint.config.CFLintPluginInfo.RuleGroup in project CFLint by cflint.
the class CFLintDoc method generateRuleMarkDown.
public static void generateRuleMarkDown(final CFLintPluginInfo pluginInfo, final PrintWriter print) {
final Map<String, String> descriptions = ConfigUtils.loadDescriptions();
final List<String> diminishParms = Arrays.asList("UnusedLocalVarChecker", "CFXTagChecker", "FunctionXChecker");
print.println("List of built-in rules and rule groups");
print.println("======================================");
print.println("## Rule Parameters ");
for (PluginInfoRule ruleInfo : pluginInfo.getRules()) {
// Do not highlight specific parameters.
if (!diminishParms.contains(ruleInfo.getClassName())) {
for (PluginParameter p : ruleInfo.getParameters()) {
print.println("<br>" + ruleInfo.getName() + "." + p.getName() + " = *" + p.getValue() + "*");
}
}
}
print.println("## Built-in rules");
for (PluginInfoRule ruleInfo : pluginInfo.getRules()) {
print.println("* " + ruleInfo.getName());
final String className = ruleInfo.getClassName() == null ? ruleInfo.getName() : ruleInfo.getClassName();
final String fullClassName = className.contains(".") ? className : "com.cflint.plugins.core." + className;
// print.println("**Class:** "+fullClassName);
if (!ruleInfo.getParameters().isEmpty()) {
print.println(" * Parameters");
for (PluginParameter p : ruleInfo.getParameters()) {
print.println(" * " + p.getName() + " = *" + p.getValue() + "*");
}
}
int counter = 1;
for (PluginMessage msg : ruleInfo.getMessages()) {
final String desc = descriptions.get(msg.getCode()) != null ? descriptions.get(msg.getCode()).replace(">", ">").replace("<", "<") : "";
print.println(" * " + msg.getCode() + " - " + desc + " *" + msg.getSeverity() + "*");
print.println(" * " + cleanUpMessage(msg, ruleInfo));
}
}
print.println("## Rule Groups");
for (final RuleGroup ruleGroup : pluginInfo.getRuleGroups()) {
print.println("### " + ruleGroup.getName());
for (final PluginMessage msg : ruleGroup.getMessages()) {
print.println(" * " + msg.getCode() + " *" + msg.getSeverity() + "*");
}
}
}
use of com.cflint.config.CFLintPluginInfo.RuleGroup in project CFLint by cflint.
the class CFLintDoc method generateRuleGroup.
public static void generateRuleGroup(final CFLintPluginInfo pluginInfo, final PrintWriter print) {
final Map<String, PluginMessage> allCodes = new LinkedHashMap<>();
for (final PluginInfoRule rule : pluginInfo.getRules()) {
for (final PluginMessage msg : rule.getMessages()) {
allCodes.put(msg.getCode(), msg);
}
}
for (final RuleGroup ruleGroup : pluginInfo.getRuleGroups()) {
print.println("Rule Group : " + ruleGroup.getName());
for (final PluginMessage msg : ruleGroup.getMessages()) {
print.println("\t" + msg.getCode() + " : " + msg.getSeverity());
allCodes.remove(msg.getCode());
}
}
if (!allCodes.isEmpty()) {
print.println("Rule Group : UNASSIGNED");
for (final PluginMessage msg : allCodes.values()) {
print.println("\t" + msg.getCode() + " : " + msg.getSeverity());
}
}
}
use of com.cflint.config.CFLintPluginInfo.RuleGroup in project CFLint by cflint.
the class TestCFLintConfig method testRuleGroups.
@Test
public /**
* Test the round trip of the config json file including rule groups.
*
* @throws JsonGenerationException
* @throws JsonMappingException
* @throws IOException
*/
void testRuleGroups() throws JsonGenerationException, JsonMappingException, IOException {
CFLintPluginInfo config = new CFLintPluginInfo();
PluginInfoRule rule = new CFLintPluginInfo.PluginInfoRule();
config.getRules().add(rule);
rule.setName("OPM");
PluginMessage message = new PluginMessage();
rule.getMessages().add(message);
message.setCode("MyCode");
message.setMessageText("messageText");
message.setSeverity(Levels.WARNING);
RuleGroup ruleGroup = new RuleGroup("r1");
ruleGroup.setDefaultSeverity(Levels.INFO);
ruleGroup.getMessages().add(message);
config.getRuleGroups().add(ruleGroup);
RuleGroup ruleGroup2 = new RuleGroup("r2");
config.getRuleGroups().add(ruleGroup2);
String jsonText = ConfigUtils.marshalJson(config);
CFLintPluginInfo backConfig = ConfigUtils.unmarshalJson(jsonText, CFLintPluginInfo.class);
assertEquals("MyCode", backConfig.getRules().get(0).getMessages().get(0).getCode());
assertEquals("messageText", backConfig.getRules().get(0).getMessages().get(0).getMessageText());
assertEquals("MyCode", backConfig.getRuleGroups().get(0).getMessages().get(0).getCode());
assertEquals("messageText", backConfig.getRuleGroups().get(0).getMessages().get(0).getMessageText());
assertEquals(Levels.INFO, backConfig.getRuleGroups().get(0).getDefaultSeverity());
}
Aggregations