use of com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage in project CFLint by cflint.
the class TestCFTagLowercaseChecker method setUp.
@Before
public void setUp() throws Exception {
final CFLintConfig conf = new CFLintConfig();
PluginInfoRule pluginRule = new PluginInfoRule();
pluginRule.setName("CFTagCaseChecker");
conf.getRules().add(pluginRule);
PluginMessage pluginMessage = new PluginMessage("CFTAG_PREFERRED_CASE");
pluginMessage.setSeverity(Levels.ERROR);
pluginMessage.setMessageText("Tag <${variable}> should be written in lowercase or camelCase for consistency in code.");
pluginRule.getMessages().add(pluginMessage);
CFLintPluginInfo pluginInfo = new CFLintPluginInfo();
pluginInfo.getRules().add(pluginRule);
pluginRule.setClassName("CFTagCaseChecker");
pluginRule.addParameter("PreferCase", "lower");
cfBugs = new CFLintAPI(new ConfigBuilder(pluginInfo).include("CFTAG_PREFERRED_CASE").build());
cfBugs.setLogError(false);
}
use of com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage 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());
}
use of com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage in project CFLint by cflint.
the class TestCFLintChainedConfig method test.
@Test
public void test() throws Exception {
assertTrue(nestConfig1.includes(new PluginMessage("ARG_VAR_CONFLICT")));
assertTrue(!nestConfig2b.includes(new PluginMessage("ARG_VAR_CONFLICT")));
assertTrue(!nestConfig1.includes(new PluginMessage("FUNCTION_HINT_MISSING")));
assertTrue(nestConfig2b.includes(new PluginMessage("FUNCTION_HINT_MISSING")));
}
use of com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage in project CFLint by cflint.
the class TestCFLintConfig2 method test.
@Test
public void test() throws Exception {
CFLintConfiguration config = com.cflint.config.ConfigUtils.unmarshal(sconfig0, CFLintConfig.class);
CFLintConfiguration config1 = com.cflint.config.ConfigUtils.unmarshal(sconfig1, CFLintConfig.class);
assertTrue(config.includes(new PluginMessage("ARG_VAR_CONFLICT")));
assertTrue(!config1.includes(new PluginMessage("ARG_VAR_CONFLICT")));
}
use of com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage in project CFLint by cflint.
the class TestCFTagUppercaseChecker method setUp.
@Before
public void setUp() throws Exception {
final CFLintConfig conf = new CFLintConfig();
PluginInfoRule pluginRule = new PluginInfoRule();
pluginRule.setName("CFTagCaseChecker");
conf.getRules().add(pluginRule);
PluginMessage pluginMessage = new PluginMessage("CFTAG_PREFERRED_CASE");
pluginMessage.setSeverity(Levels.ERROR);
pluginMessage.setMessageText("Tag <${variable}> should be written in lowercase or camelCase for consistency in code.");
pluginRule.getMessages().add(pluginMessage);
CFLintPluginInfo pluginInfo = new CFLintPluginInfo();
pluginInfo.getRules().add(pluginRule);
pluginRule.setClassName("CFTagCaseChecker");
pluginRule.addParameter("PreferCase", "upper");
cfBugs = new CFLintAPI(new ConfigBuilder(pluginInfo).include("CFTAG_PREFERRED_CASE").build());
cfBugs.setLogError(false);
}
Aggregations