use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestBooleanExpressionChecker method testIfBooleanExpressionInTag.
@Test
public void testIfBooleanExpressionInTag() throws CFLintScanException {
final String tagSrc = "<cfif a and b is true>\r\n" + "<cfset c = 1>\r\n" + "<cfelseif a or b is false>\r\n" + "<cfset c = 2>\r\n" + "<cfelse>\r\n" + "<cfset c = 3>\r\n" + "</cfif>\r\n";
CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(2, result.size());
assertEquals("EXPLICIT_BOOLEAN_CHECK", result.get(0).getMessageCode());
assertEquals(1, result.get(0).getLine());
assertEquals("EXPLICIT_BOOLEAN_CHECK", result.get(1).getMessageCode());
assertEquals(3, result.get(1).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestBooleanExpressionChecker method testReturnBooleanExpressionInTag.
@Test
public void testReturnBooleanExpressionInTag() throws CFLintScanException {
final String tagSrc = "<cffunction name=\"test\">\r\n" + "<cfreturn (e and f) is true>\r\n" + "</cffunction>";
CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("EXPLICIT_BOOLEAN_CHECK", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs method testSimpleCFQUERYIssue30b_OK.
@Test
public void testSimpleCFQUERYIssue30b_OK() throws CFLintScanException {
final String cfcSrc = " <cfoutput query=\"qryPopups\" group=\"id\">\n" + " <cfoutput group=\"id2\">\n" + " <cfif message NEQ \"\" and not(ListFind(arraytoList( arguments.quote.getErrorHandler().getShownErrors()),id))>\n" + " <cfoutput>#message####id#|</cfoutput>\n" + " <cfset arrayappend(arguments.quote.getErrorHandler().getShownErrors(),id)>\n" + " </cfif>\n" + " <cflog file=\"Quote_#quote.getOnlineNumber()#\" text=\"Popup:#message#,#id#\" type=\"informational\">\n" + " </cfoutput>\r\n" + " </cfoutput>\r\n";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
assertEquals(0, lintresult.getIssues().size());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs method testMissingSemiTag2.
@Test
public void testMissingSemiTag2() throws CFLintScanException {
String src = "<cfscript> name_1 \n" + " name2 = \"Smith\"\n</cfscript>";
CFLintResult lintresult = cfBugs.scan(src, "test");
List<BugInfo> list = lintresult.getIssues().get("MISSING_SEMI");
assertNotNull(list);
assertEquals(1, list.size());
assertEquals(18, src.indexOf("name_1") + "name_1".length() - 1);
assertEquals(18, list.get(0).getOffset());
assertEquals(1, list.get(0).getLine());
assertEquals(18, list.get(0).getColumn());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs method testSimpleCFQUERYNested.
@Test
public void testSimpleCFQUERYNested() throws CFLintScanException {
final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <cfoutput query=\"q123\">\r\n" + " <cfset var y=123/>\r\n" + " <cfoutput>#y#</cfoutput>\r\n" + " </cfoutput>\r\n" + "</cffunction>\r\n" + "/<cfcomponent>";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("NESTED_CFOUTPUT", result.get(0).getMessageCode());
assertEquals(5, result.get(0).getLine());
}
Aggregations