Search in sources :

Example 76 with CFLintResult

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

the class TestCFBugs_MethodNames method nameTooLongScript.

@Test
public void nameTooLongScript() throws CFLintScanException {
    final String scriptSrc = "component {\r\n" + "function isaveryveryverylongmethodname() {\r\n" + "}\r\n" + "}";
    CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("METHOD_TOO_LONG", result.get(0).getMessageCode());
    assertEquals(2, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 77 with CFLintResult

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

the class TestCFBugs_MethodNames method testValidNamesScript.

@Test
public void testValidNamesScript() throws CFLintScanException {
    final String scriptSrc = "component {\r\n" + "function test() {\r\n" + "}\r\n" + "}";
    CFLintResult lintresult = cfBugs.scan(scriptSrc, "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 78 with CFLintResult

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

the class TestCFBugs_OutputDef method test_OK.

@Test
public void test_OK() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent output=\"false\">\r\n" + "<cffunction name=\"test\" output=\"false\">\r\n" + "	<cfargument name=\"xyz\" default=\"\">\r\n" + "	<cfset var xyz=123/>\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)

Example 79 with CFLintResult

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

the class TestCFBugs_ParseError method testParseErrorLine1.

@Test
public void testParseErrorLine1() throws CFLintScanException {
    final String cfcSrc = "<cfif \"foo\" ==== \"bar\">Foo</cfif>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    List<BugInfo> result = lintresult.getIssues().get("PARSE_ERROR");
    assertEquals(result.toString(), 1, result.size());
    assertEquals("PARSE_ERROR", result.get(0).getMessageCode());
    assertEquals(1, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 80 with CFLintResult

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

the class TestCFBugs_QueryParams method testCFScript_QueryParams_DynamicTableName.

@Test
public void testCFScript_QueryParams_DynamicTableName() throws CFLintScanException {
    final String cfcSrc = "<cfquery name=\"queryName\" datasource=\"#datasourceName#\">\n" + "    update #tableName#\n" + "    set fieldName = 'foo'\n" + "</cfquery>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("CFQUERYPARAM_REQ", result.get(0).getMessageCode());
    assertEquals("tableName", result.get(0).getVariable());
}
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