use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_VarScoper method testVarScoperCharOffset.
@Test
public void testVarScoperCharOffset() throws CFLintScanException {
String src = "<cfscript>component {\r\n" + "public any function process(){\r\n" + " x=123;\r\n" + "}\r\n" + "}</cfscript>";
CFLintResult lintresult = cfBugs.scan(src, "test");
List<BugInfo> list = lintresult.getIssues().get("MISSING_VAR");
assertEquals(1, list.size());
assertEquals("test", list.get(0).getFilename());
assertEquals("process", list.get(0).getFunction());
assertEquals(3, list.get(0).getLine());
assertEquals(4, list.get(0).getColumn());
assertEquals(58, src.indexOf('x'));
assertEquals(58, list.get(0).getOffset());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_VarScoper_TagAttr method runTagAttrTest.
public void runTagAttrTest(final String tag, final String attr, final String variable) throws CFLintScanException {
final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <" + tag + " " + attr + "=\"" + variable + "\">\r\n" + " </" + tag + ">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
assertEquals(1, lintresult.getIssues().size());
List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("MISSING_VAR", result.get(0).getMessageCode());
assertEquals(variable, result.get(0).getVariable());
assertEquals(3, result.get(0).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_VariableNames method nameIsTemporyTag.
@Test
public void nameIsTemporyTag() throws CFLintScanException {
final String tagSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <cfset temp = \"Fred\">\r\n" + " <cfset name.temp = \"Fred\">\r\n" + " <cfset obj = \"Fred\">\r\n" + " <cfset struct = \"Fred\">\r\n" + " <cfset tempName = \"Fred\">\r\n" + " <cfset nameObj = \"Fred\">\r\n" + " <cfset nameString = \"Fred\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
final List<BugInfo> result = lintresult.getIssues().get("VAR_IS_TEMPORARY");
assertEquals(6, result.size());
assertEquals("VAR_IS_TEMPORARY", result.get(0).getMessageCode());
assertEquals(3, result.get(0).getLine());
assertEquals("VAR_IS_TEMPORARY", result.get(1).getMessageCode());
assertEquals(5, result.get(1).getLine());
assertEquals("VAR_IS_TEMPORARY", result.get(2).getMessageCode());
assertEquals(6, result.get(2).getLine());
assertEquals("VAR_IS_TEMPORARY", result.get(3).getMessageCode());
assertEquals(7, result.get(3).getLine());
assertEquals("VAR_IS_TEMPORARY", result.get(4).getMessageCode());
assertEquals(8, result.get(4).getLine());
assertEquals("VAR_IS_TEMPORARY", result.get(5).getMessageCode());
assertEquals(9, result.get(5).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_VariableNames method nameTooShortScript.
@Test
public void nameTooShortScript() throws CFLintScanException {
final String scriptSrc = "component {\r\n" + "function test() {\r\n" + " a = \"Fred\";\r\n" + " b = \"Smith\";\r\n" + " last.a = \"Fred\";\r\n" + "}\r\n" + "}";
CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(2, result.size());
assertEquals("VAR_TOO_SHORT", result.get(0).getMessageCode());
assertEquals(3, result.get(0).getLine());
assertEquals("VAR_TOO_SHORT", result.get(1).getMessageCode());
assertEquals(4, result.get(1).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_VariableNames method testUpercaseNameScript.
@Test
public void testUpercaseNameScript() throws CFLintScanException {
final String scriptSrc = "component {\r\n" + "function test() {\r\n" + " var FIRSTNAME = \"Fred\";\r\n" + " LAST_NAME = \"Smith\";\r\n" + " names = {};\r\n" + " name.FIRST = \"Fred\";\r\n" + " NAMES[1] = \"Fred\";\r\n" + " local.NAME = \"Fred\";\r\n" + "}\r\n" + "}";
CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("VAR_ALLCAPS_NAME", result.get(0).getMessageCode());
assertEquals(8, result.get(0).getLine());
}
Aggregations