Search in sources :

Example 21 with CFLintResult

use of com.cflint.api.CFLintResult in project CFLint by cflint.

the class TestCFBugs method testCFScriptFor.

@Test
public void testCFScriptFor() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"rateBop\" >\r\n" + "<cfargument name=\"quote\">\r\n" + "\r\n" + "<cfscript>\r\n" + "for (i = 0; i < 100; i + 5) {\r\n" + "xx=123;\r\n" + "}\r\n" + "</cfscript>\r\n" + "</cffunction>" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(2, result.size());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 22 with CFLintResult

use of com.cflint.api.CFLintResult in project CFLint by cflint.

the class TestCFBugs method testCFScriptCfc.

@Test
public void testCFScriptCfc() throws CFLintScanException {
    final String cfcSrc = "/** \r\n" + "* Simple Component. \r\n" + "*/ \r\n" + "component { \r\n" + "/** \r\n" + "* Simple function. \r\n" + "*/ \r\n" + "public void function foo() { \r\n" + "xx=123; \r\n" + "} \r\n" + "}";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("MISSING_VAR", result.get(0).getMessageCode());
    assertEquals(9, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 23 with CFLintResult

use of com.cflint.api.CFLintResult in project CFLint by cflint.

the class TestCFBugs method testSimpleCFSETNoParse.

@Test
public void testSimpleCFSETNoParse() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfset x=123/>" + "	<cfset var y=123/>\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    // Note
    assertEquals("MISSING_VAR", result.get(0).getMessageCode());
// parsing
// error
// fixed
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 24 with CFLintResult

use of com.cflint.api.CFLintResult in project CFLint by cflint.

the class TestCFBugs method testCFScriptForUnVarred.

@Test
public void testCFScriptForUnVarred() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"func1\">\r\n" + "	<cfscript>\r\n" + "			for (a=1;a LTE arraylen(d); a=a+1) {\r\n" + "				if(d[a].getName() EQ drawer){\r\n" + "					return d[a];\r\n" + "				}\r\n" + "			}\r\n" + "	</cfscript>\r\n" + "</cffunction>" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("MISSING_VAR", result.get(0).getMessageCode());
    assertEquals(4, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 25 with CFLintResult

use of com.cflint.api.CFLintResult in project CFLint by cflint.

the class TestCFBugs method testSimpleCFQUERYIssue30.

@Test
public void testSimpleCFQUERYIssue30() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfoutput query=\"qryPopups\" group=\"id\">\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" + "</cffunction>\r\n" + "/<cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    assertEquals(0, lintresult.getIssues().size());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Aggregations

CFLintResult (com.cflint.api.CFLintResult)298 Test (org.junit.Test)289 List (java.util.List)70 CFLintAPI (com.cflint.api.CFLintAPI)2 StringWriter (java.io.StringWriter)2 Ignore (org.junit.Ignore)2 CFLintConfiguration (com.cflint.config.CFLintConfiguration)1 CFLintConfigurationException (com.cflint.exception.CFLintConfigurationException)1 CFLintScanException (com.cflint.exception.CFLintScanException)1 MarshallerException (com.cflint.xml.MarshallerException)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 Writer (java.io.Writer)1 JAXBException (javax.xml.bind.JAXBException)1 TransformerException (javax.xml.transform.TransformerException)1