use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_SimpleComplexity method testComplexTagBased.
@Test
public void testComplexTagBased() throws CFLintScanException {
final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"functionTwo\">\r\n" + "<cfif a is 1>\r\n" + "<cfset b = 1>\r\n" + "<cfelseif a is 2>\r\n" + "<cfset b = 2>\r\n" + "<cfelseif a is 3>\r\n" + "<cfset b = 3>\r\n" + "<cfelseif a is 4>\r\n" + "<cfset b = 4>\r\n" + "<cfelseif a is 5>\r\n" + "<cfset b = 5>\r\n" + "<cfelseif a is 6>\r\n" + "<cfset b = 6>\r\n" + "<cfelseif a is 7>\r\n" + "<cfset b = 7>\r\n" + "<cfelseif a is 8>\r\n" + "<cfset b = 8>\r\n" + "<cfelseif a is 9>\r\n" + "<cfset b = 9>\r\n" + "<cfelseif a is 10>\r\n" + "<cfset b = 10>\r\n" + "<cfelseif a is 11>\r\n" + "<cfset b = 11>\r\n" + "</cfif>\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
assertNotNull(result);
assertEquals(1, result.size());
assertEquals("FUNCTION_TOO_COMPLEX", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_SimpleComplexity method testComplexSwitchScriptBased.
@Test
public void testComplexSwitchScriptBased() throws CFLintScanException {
final String cfcSrc = "component {\r\n" + "function functionFive() {\r\n" + "switch(a) {\r\n" + "case 1:\r\n" + "b = 1;\r\n" + "break;\r\n" + "case 2:\r\n" + "b = 2;\r\n" + "break;\r\n" + "case 3:\r\n" + "b = 3;\r\n" + "break;\r\n" + "case 4:\r\n" + "b = 4;\r\n" + "break;\r\n" + "case 5:\r\n" + "b = 5;\r\n" + "break;\r\n" + "case 6:\r\n" + "b = 6;\r\n" + "break;\r\n" + "case 7:\r\n" + "b = 7;\r\n" + "break;\r\n" + "case 8:\r\n" + "b = 8;\r\n" + "break;\r\n" + "case 9:\r\n" + "b = 9;\r\n" + "break;\r\n" + "case 10:\r\n" + "b = 10;\r\n" + "break;\r\n" + "case 11:\r\n" + "b = 11;\r\n" + "break;\r\n" + "}\r\n" + "}\r\n" + "}";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
final List<BugInfo> result = lintresult.getIssues().get("FUNCTION_TOO_COMPLEX");
assertNotNull(result);
assertEquals(1, result.size());
assertEquals(cfcSrc.indexOf("function"), result.get(0).getOffset());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_SimpleComplexity method testComplexScriptBased.
@Test
public void testComplexScriptBased() throws CFLintScanException {
final String cfcSrc = "component {\r\n" + "function functionFour() {\r\n" + "if (a == 1) {" + "b = 1;\r\n" + "}\r\n" + "else if (a == 2) {\r\n" + "b = 2;\r\n" + "}\r\n" + "else if (a == 3) {\r\n" + "b = 3;\r\n" + "}\r\n" + "else if (a == 4) {\r\n" + "b = 4;\r\n" + "}\r\n" + "else if (a == 5) {\r\n" + "b = 5;\r\n" + "}\r\n" + "else if (a == 6) {\r\n" + "b = 6;\r\n" + "}\r\n" + "else if (a == 7) {\r\n" + "b = 7;\r\n" + "}\r\n" + "else if (a == 8) {\r\n" + "b = 8;\r\n" + "}\r\n" + "else if (a == 9) {\r\n" + "b = 9;\r\n" + "}\r\n" + "else if (a == 10) {\r\n" + "b = 10;\r\n" + "else if (a == 11) {\r\n" + "b = 11;\r\n" + "}\r\n" + "}\r\n" + "}";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
final List<BugInfo> result = lintresult.getIssues().get("FUNCTION_TOO_COMPLEX");
assertNotNull(result);
assertEquals(1, result.size());
assertEquals("FUNCTION_TOO_COMPLEX", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_SimpleComplexity method testIfStatementNoElse.
@Test
public void testIfStatementNoElse() throws CFLintScanException {
final String cfcSrc = "component {\r\n" + " public void function foo() {\r\n" + " if (something) {\r\n" + " doSomething();\r\n" + " }\r\n" + " }\r\n" + "}";
CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
Collection<List<BugInfo>> result = lintresult.getIssues().values();
assertEquals(0, result.size());
}
use of com.cflint.api.CFLintResult in project CFLint by cflint.
the class TestCFBugs_TooManyArguments method testLargeNumberTagBased.
@Test
public void testLargeNumberTagBased() throws CFLintScanException {
final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + " <cfargument name=\"argumentOne\">\r\n" + " <cfargument name=\"argumentTwo\">\r\n" + " <cfargument name=\"argumentThree\">\r\n" + " <cfargument name=\"argumentFour\">\r\n" + " <cfargument name=\"argumentFive\">\r\n" + " <cfargument name=\"argumentSiX\">\r\n" + " <cfargument name=\"argumentSeven\">\r\n" + " <cfargument name=\"argumentEight\">\r\n" + " <cfargument name=\"argumentNone\">\r\n" + " <cfargument name=\"argumentTen\">\r\n" + " <cfargument name=\"argumentEleven\">\r\n" + " <cfargument name=\"argumentTwelve\">\r\n" + " <cfset var a = 1>\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("EXCESSIVE_ARGUMENTS", result.get(0).getMessageCode());
assertEquals(2, result.get(0).getLine());
}
Aggregations