Skip to content

Commit

Permalink
Merge pull request #76 from cflint/cfabort
Browse files Browse the repository at this point in the history
Cfabort
  • Loading branch information
justinmclean committed Oct 9, 2015
2 parents 94b8a90 + 3257b16 commit e1b9586
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/resources/cflint.definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
</message>
<parameter name="tagName" value="cfdump"/>
</ruleImpl>
<ruleImpl name="CFAbortChecker" className="CFXTagChecker">
<message code="AVOID_USING_CFABORT_TAG">
<messageText>Avoid Leaving &lt;${tagName}&gt; tags in committed code. Did you accidently leave a cfabort in the code?</messageText>
<severity>INFO</severity>
</message>
<parameter name="tagName" value="cfabort"/>
</ruleImpl>
<ruleImpl name="CFInsertChecker" className="CFXTagChecker">
<message code="AVOID_USING_CFINSERT_TAG">
<messageText>Avoid using &lt;${tagName}&gt; tags. Use cfquery and cfstoredproc instead.</messageText>
Expand Down
47 changes: 47 additions & 0 deletions src/test/java/com/cflint/TestCFAbortChecker.java
Original file line number Diff line number Diff line change
@@ -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 = "<cfabort>";
cfBugs.process(cfcSrc, "test");
assertEquals(1, cfBugs.getBugs().getBugList().size());
assertEquals("Avoid Leaving <cfabort> tags in committed code.",
cfBugs.getBugs().getFlatBugList().get(0).getMessage());
}

}

0 comments on commit e1b9586

Please sign in to comment.