Search in sources :

Example 26 with CFLintResult

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

the class TestCFBugs method testCFScriptIf.

@Test
public void testCFScriptIf() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"rateBop\" >\r\n" + "<cfargument name=\"quote\">\r\n" + "\r\n" + "<cfscript>\r\n" + "if (xx) {\r\n" + "yy=123;\r\n" + "}else{\r\n" + "zz=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 27 with CFLintResult

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

the class TestCFBugs method testCFScriptAStruct.

@Test
public void testCFScriptAStruct() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"func1\">\r\n" + "	<cfscript>\r\n" + "		var a = {};\r\n" + "		a.response = processRequest(argumentCollection=arguments);\r\n" + "	</cfscript>\r\n" + "</cffunction>" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    assertEquals(0, lintresult.getIssues().size());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 28 with CFLintResult

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

the class TestCFBugs method testMissingSemiTag.

@Test
public void testMissingSemiTag() throws CFLintScanException {
    String src = "<cfcomponent>\n" + "<cfscript> function test() {\n" + " name_1 \n" + "    name2 = \"Smith\"\n" + " last.name1 = \"Fred\"\n" + " }\n" + "</cfscript> </component>";
    CFLintResult lintresult = cfBugs.scan(src, "test");
    List<BugInfo> list = lintresult.getIssues().get("MISSING_SEMI");
    assertNotNull(list);
    assertEquals(1, list.size());
    assertEquals(49, src.indexOf("name_1") + "name_1".length() - 1);
    assertEquals(49, list.get(0).getOffset());
    assertEquals(3, list.get(0).getLine());
    assertEquals(6, list.get(0).getColumn());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 29 with CFLintResult

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

the class TestCFBugs method testSimpleCFSETArg.

@Test
public void testSimpleCFSETArg() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "<cfargument name=\"x\" default=\"\">\r\n" + "	<cfif 1 EQ 1>\r\n" + "	<cfset x=123/>\r\n" + "	<cfset var y=123/>\r\n" + "	</cfif>\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    Collection<List<BugInfo>> result = lintresult.getIssues().values();
    assertEquals(0, result.size());
}
Also used : List(java.util.List) CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 30 with CFLintResult

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

the class TestCFBugs method testMissingSemi.

@Test
public void testMissingSemi() throws CFLintScanException {
    String src = "component {\n" + " function test() {\n" + "   name_1 \n" + "    name2 = \"Smith\"\n" + " last.name1 = \"Fred\"\n" + " }\n" + "}";
    CFLintResult lintresult = cfBugs.scan(src, "test");
    List<BugInfo> list = lintresult.getIssues().get("MISSING_SEMI");
    assertNotNull(list);
    assertEquals(1, list.size());
    assertEquals(3, list.get(0).getLine());
    assertEquals(8, list.get(0).getColumn());
    assertEquals(39, src.indexOf("name_1") + "name_1".length() - 1);
    assertEquals(39, list.get(0).getOffset());
}
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