use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestArgumentNames method invalidCharsInNameScript.
@Test
public void invalidCharsInNameScript() throws CFLintScanException {
final String scriptSrc = "component {\r\n" + "function test($name, last$name) {\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_INVALID_NAME", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
assertEquals("ARGUMENT_INVALID_NAME", result.get(1).getMessageCode());
assertEquals(2, result.get(1).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestArgumentNames method nameHasPrefixOrPostfixTag.
@Test
public void nameHasPrefixOrPostfixTag() throws CFLintScanException {
final String tagSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <cfargument name=\"sName\">\r\n" + " <cfargument name=\"nameSt\">\r\n" + " <cfargument name=\"oName\">\r\n" + " <cfargument name=\"bOff\">\r\n" + " <cfargument name=\"arrNames\">\r\n" + " <cfargument name=\"thisName\">\r\n" + " <cfargument name=\"myName\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(7, result.size());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(0).getMessageCode());
assertEquals(3, result.get(0).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(1).getMessageCode());
assertEquals(4, result.get(1).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(2).getMessageCode());
assertEquals(5, result.get(2).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(3).getMessageCode());
assertEquals(6, result.get(3).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(4).getMessageCode());
assertEquals(7, result.get(4).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(5).getMessageCode());
assertEquals(8, result.get(5).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(6).getMessageCode());
assertEquals(9, result.get(6).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestArgumentNames method nameIsTemporyTag.
@Test
public void nameIsTemporyTag() throws CFLintScanException {
final String tagSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <cfargument name=\"temp\">\r\n" + " <cfargument name=\"obj\">\r\n" + " <cfargument name=\"struct\">\r\n" + " <cfargument name=\"tempName\">\r\n" + " <cfargument name=\"nameObj\">\r\n" + " <cfargument name=\"nameString\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
final List<BugInfo> result = lintresult.getIssues().get("ARGUMENT_IS_TEMPORARY");
assertEquals(6, result.size());
assertEquals("ARGUMENT_IS_TEMPORARY", result.get(0).getMessageCode());
assertEquals(3, result.get(0).getLine());
assertEquals("ARGUMENT_IS_TEMPORARY", result.get(1).getMessageCode());
assertEquals(4, result.get(1).getLine());
assertEquals("ARGUMENT_IS_TEMPORARY", result.get(2).getMessageCode());
assertEquals(5, result.get(2).getLine());
assertEquals("ARGUMENT_IS_TEMPORARY", result.get(3).getMessageCode());
assertEquals(6, result.get(3).getLine());
assertEquals("ARGUMENT_IS_TEMPORARY", result.get(4).getMessageCode());
assertEquals(7, result.get(4).getLine());
assertEquals("ARGUMENT_IS_TEMPORARY", result.get(5).getMessageCode());
assertEquals(8, result.get(5).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestArgumentNames method nameTooLongScript.
@Test
public void nameTooLongScript() throws CFLintScanException {
final String scriptSrc = "component {\r\n" + "function test(isaveryveryverylongvariablename) {\r\n" + "}\r\n" + "}";
CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("ARGUMENT_TOO_LONG", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestArgumentNames method nameHasPrefixOrPostfixScript.
@Test
public void nameHasPrefixOrPostfixScript() throws CFLintScanException {
final String scriptSrc = "component {\r\n" + "function test(aName, nameSt, oName, bOff, arrNames, thisName, myName) {\r\n" + "}\r\n" + "}";
CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(7, result.size());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(1).getMessageCode());
assertEquals(2, result.get(1).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(2).getMessageCode());
assertEquals(2, result.get(2).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(3).getMessageCode());
assertEquals(2, result.get(3).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(4).getMessageCode());
assertEquals(2, result.get(4).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(5).getMessageCode());
assertEquals(2, result.get(5).getLine());
assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(6).getMessageCode());
assertEquals(2, result.get(6).getLine());
}
Aggregations