Search in sources :

Example 11 with PluginInfoRule

use of com.cflint.config.CFLintPluginInfo.PluginInfoRule in project CFLint by cflint.

the class TestCFCustomTagChecker method setUp.

@Before
public void setUp() throws Exception {
    final CFLintConfig conf = new CFLintConfig();
    final PluginInfoRule pluginRuleX = new PluginInfoRule();
    pluginRuleX.setName("CFXTagChecker");
    conf.getRules().add(pluginRuleX);
    final PluginMessage pluginMessageX = new PluginMessage("AVOID_USING_MYLIB:CFCUSTOMTAG_TAG");
    pluginMessageX.setSeverity(Levels.WARNING);
    pluginMessageX.setMessageText("Avoid Leaving <${tagName}> tags in committed code. Debug information should be ommited from release code");
    pluginRuleX.getMessages().add(pluginMessageX);
    pluginRuleX.addParameter("tagName", ".*:cfcustomtag");
    CFLintPluginInfo pluginInfo = new CFLintPluginInfo();
    pluginInfo.getRules().add(pluginRuleX);
    pluginRuleX.setClassName("CFXTagChecker");
    cfBugs = new CFLintAPI(new ConfigBuilder(pluginInfo).include("AVOID_USING_MYLIB:CFCUSTOMTAG_TAG").build());
    cfBugs.setLogError(false);
}
Also used : CFLintAPI(com.cflint.api.CFLintAPI) CFLintPluginInfo(com.cflint.config.CFLintPluginInfo) CFLintConfig(com.cflint.config.CFLintConfig) PluginMessage(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage) ConfigBuilder(com.cflint.config.ConfigBuilder) PluginInfoRule(com.cflint.config.CFLintPluginInfo.PluginInfoRule) Before(org.junit.Before)

Example 12 with PluginInfoRule

use of com.cflint.config.CFLintPluginInfo.PluginInfoRule 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);
}
Also used : CFLintAPI(com.cflint.api.CFLintAPI) CFLintPluginInfo(com.cflint.config.CFLintPluginInfo) CFLintConfig(com.cflint.config.CFLintConfig) PluginMessage(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage) ConfigBuilder(com.cflint.config.ConfigBuilder) PluginInfoRule(com.cflint.config.CFLintPluginInfo.PluginInfoRule) Before(org.junit.Before)

Example 13 with PluginInfoRule

use of com.cflint.config.CFLintPluginInfo.PluginInfoRule 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);
}
Also used : CFLintAPI(com.cflint.api.CFLintAPI) CFLintPluginInfo(com.cflint.config.CFLintPluginInfo) CFLintConfig(com.cflint.config.CFLintConfig) PluginMessage(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage) ConfigBuilder(com.cflint.config.ConfigBuilder) PluginInfoRule(com.cflint.config.CFLintPluginInfo.PluginInfoRule) Before(org.junit.Before)

Example 14 with PluginInfoRule

use of com.cflint.config.CFLintPluginInfo.PluginInfoRule 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());
}
Also used : PluginMessage(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage) PluginInfoRule(com.cflint.config.CFLintPluginInfo.PluginInfoRule) RuleGroup(com.cflint.config.CFLintPluginInfo.RuleGroup) Test(org.junit.Test)

Aggregations

PluginInfoRule (com.cflint.config.CFLintPluginInfo.PluginInfoRule)14 PluginMessage (com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage)11 CFLintPluginInfo (com.cflint.config.CFLintPluginInfo)6 CFLintConfig (com.cflint.config.CFLintConfig)5 RuleGroup (com.cflint.config.CFLintPluginInfo.RuleGroup)4 ConfigBuilder (com.cflint.config.ConfigBuilder)4 CFLintAPI (com.cflint.api.CFLintAPI)3 PluginParameter (com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginParameter)3 Before (org.junit.Before)3 LinkedHashMap (java.util.LinkedHashMap)2 Test (org.junit.Test)2 CFExpression (cfml.parsing.cfscript.CFExpression)1 CFStatement (cfml.parsing.cfscript.CFStatement)1 CFScriptStatement (cfml.parsing.cfscript.script.CFScriptStatement)1 BugInfoBuilder (com.cflint.BugInfo.BugInfoBuilder)1 CFLintChainedConfig (com.cflint.config.CFLintChainedConfig)1 CFLintConfigurationException (com.cflint.exception.CFLintConfigurationException)1 CFLintScanException (com.cflint.exception.CFLintScanException)1 CFLintScanner (com.cflint.plugins.CFLintScanner)1 MarshallerException (com.cflint.xml.MarshallerException)1