use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestArgumentNames method nameTooShortScript.
@Test
public void nameTooShortScript() throws CFLintScanException {
final String scriptSrc = "component {\r\n" + "function test(a, b) {\r\n" + "}\r\n" + "}";
CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(2, result.size());
assertEquals("ARGUMENT_TOO_SHORT", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
assertEquals("ARGUMENT_TOO_SHORT", result.get(1).getMessageCode());
assertEquals(2, result.get(1).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestArrayNewChecker method testArrayNewMultiDimentionInScript.
@Test
public void testArrayNewMultiDimentionInScript() throws CFLintScanException {
final String scriptSrc = "<cfscript>\r\n" + "var a = 23;\r\n" + "var b = arrayNew(3);\r\n" + "</cfscript>";
CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
assertEquals(0, lintresult.getIssues().size());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestArrayNewChecker method testArrayNewInTag.
@Test
public void testArrayNewInTag() throws CFLintScanException {
final String tagSrc = "<cfset a = 23>\r\n" + "<cfset b = arrayNew(1)>";
CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("AVOID_USING_ARRAYNEW", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
assertEquals(Levels.INFO, result.get(0).getSeverity());
assertEquals("Use implict array construction instead (= []).", result.get(0).getMessage());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestBooleanExpressionChecker method testReturnBooleanExpressionInScript.
@Test
public void testReturnBooleanExpressionInScript() throws CFLintScanException {
final String scriptSrc = "component {\r\n" + "public function test() {\r\n" + "return (x && y) == true;\r\n" + "}\r\n" + "}\r\n";
CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("EXPLICIT_BOOLEAN_CHECK", result.get(0).getMessageCode());
assertEquals(3, result.get(0).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestBooleanExpressionChecker method testSetBooleanExpressionInScript.
@Test
public void testSetBooleanExpressionInScript() throws CFLintScanException {
final String scriptSrc = "<cfscript>\r\n" + "x = (a && b) == true;\r\n" + "</cfscript>";
CFLintResult lintresult = cfBugs.scan(scriptSrc, "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());
}
Aggregations