Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cfabort #76

Merged
merged 3 commits into from
Oct 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}

}