use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_ArgsHint method testMissingHint.
@Test
public void testMissingHint() throws CFLintScanException {
final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <cfargument name=\"xyz\" default=\"123\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("ARG_HINT_MISSING", result.get(0).getMessageCode());
assertEquals(3, result.get(0).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_ArgsType method testMissingTypeNoTags.
@Test
public void testMissingTypeNoTags() throws CFLintScanException {
final String cfcSrc = "component {\r\n" + "public void function test(arg1) {\r\n" + "}\r\n" + "}\r\n";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertEquals(1, result.size());
assertEquals("ARG_TYPE_MISSING", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
assertEquals(Levels.WARNING, result.get(0).getSeverity());
assertEquals("Argument arg1 is missing a type.", result.get(0).getMessage());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_ArgsUse method testVarAndArgs_Struct.
@Test
public void testVarAndArgs_Struct() throws CFLintScanException {
final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <cfargument name=\"page\" default=\"\">\r\n" + " <cfset variables.instance.page = arguments.page />\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
assertEquals(lintresult.getIssues().toString(), 0, lintresult.getIssues().size());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_ArgsUse method testVarAndArgs_MixedUse_2x.
@Test
public void testVarAndArgs_MixedUse_2x() throws CFLintScanException {
final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <cfargument name=\"xyz\" default=\"\">\r\n" + " <cfset xyz=123/>\r\n" + " <cfset y=arguments.xyz/>\r\n" + " <cfset z=arguments.xyz/>\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("ARG_VAR_MIXED", result.get(0).getMessageCode());
assertEquals(5, result.get(0).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_ArgsUse method testVarAndArgs_Cfscript_OK.
@Test
public void testVarAndArgs_Cfscript_OK() throws CFLintScanException {
final String cfcSrc = "component { \r\n" + "public void function foo(any arg1=\"\") { \r\n" + "arg1=123; \r\n" + "} \r\n" + "}";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
assertEquals(0, lintresult.getIssues().size());
}
Aggregations