diff --git a/src/main/resources/cflint.definition.xml b/src/main/resources/cflint.definition.xml index cf8bc961b..c02aa57e2 100644 --- a/src/main/resources/cflint.definition.xml +++ b/src/main/resources/cflint.definition.xml @@ -73,6 +73,13 @@ + + + Avoid Leaving <${tagName}> tags in committed code. Did you accidently leave a cfabort in the code? + INFO + + + Avoid using <${tagName}> tags. Use cfquery and cfstoredproc instead. diff --git a/src/test/java/com/cflint/TestCFAbortChecker.java b/src/test/java/com/cflint/TestCFAbortChecker.java new file mode 100644 index 000000000..0045ce4fe --- /dev/null +++ b/src/test/java/com/cflint/TestCFAbortChecker.java @@ -0,0 +1,47 @@ +package com.cflint; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.junit.Before; +import org.junit.Test; + +import cfml.parsing.reporting.ParseException; + +import com.cflint.config.CFLintPluginInfo.PluginInfoRule; +import com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginMessage; +import com.cflint.config.ConfigRuntime; +import com.cflint.plugins.core.CFXTagChecker; + +public class TestCFAbortChecker { + + private CFLint cfBugs; + + @Before + public void setUp() { + final ConfigRuntime conf = new ConfigRuntime(); + final PluginInfoRule pluginRule = new PluginInfoRule(); + pluginRule.setName("CFXTagChecker"); + pluginRule.addParameter("tagName", "cfabort"); + conf.getRules().add(pluginRule); + final PluginMessage pluginMessage = new PluginMessage("AVOID_USING_CFABORT_TAG"); + pluginMessage.setSeverity("INFO"); + pluginMessage.setMessageText("Avoid Leaving <${tagName}> tags in committed code."); + pluginRule.getMessages().add(pluginMessage); + final CFXTagChecker checker = new CFXTagChecker(); + checker.setParameter("tagName", "cfabort"); + cfBugs = new CFLint(conf, checker); + } + + @Test + public void test_BAD() throws ParseException, IOException { + + final String cfcSrc = ""; + cfBugs.process(cfcSrc, "test"); + assertEquals(1, cfBugs.getBugs().getBugList().size()); + assertEquals("Avoid Leaving tags in committed code.", + cfBugs.getBugs().getFlatBugList().get(0).getMessage()); + } + +}