Search in sources :

Example 66 with CFLintResult

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

the class TestCFBugs_FunctionType method testReturnTypeAny.

@Test
public void testReturnTypeAny() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\" returnType=\"any\">\r\n" + "	<cfargument name=\"xyz\" default=\"123\" type=\"any\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>\r\n";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("FUNCTION_TYPE_ANY", result.get(0).getMessageCode());
    assertEquals(2, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 67 with CFLintResult

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

the class TestCFBugs_GLobalVarChecker method testHashLiteralNestedCGI.

@Test
public void testHashLiteralNestedCGI() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfset a.books = '#CGI.user.books#'>\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("GLOBAL_VAR", result.get(0).getMessageCode());
    assertEquals("CGI", result.get(0).getVariable());
    assertEquals(3, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 68 with CFLintResult

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

the class TestCFBugs_GLobalVarChecker method testApplication_1x.

@Test
public void testApplication_1x() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfset application.bf=\"123\">\r\n" + "	<cfset application.another=\"123\">\r\n" + "	<cfset form.id=\"123\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(2, result.size());
    assertEquals("GLOBAL_VAR", result.get(0).getMessageCode());
    assertEquals("application", result.get(0).getVariable());
    assertEquals(3, result.get(0).getLine());
    assertEquals("GLOBAL_VAR", result.get(1).getMessageCode());
    assertEquals("form", result.get(1).getVariable());
    assertEquals(5, result.get(1).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 69 with CFLintResult

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

the class TestCFBugs_GLobalVarChecker method testCGI.

@Test
public void testCGI() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfset CGI.bf=\"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("GLOBAL_VAR", result.get(0).getMessageCode());
    assertEquals("CGI", result.get(0).getVariable());
    assertEquals(3, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 70 with CFLintResult

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

the class TestCFBugs_GLobalVarChecker method testHashNestedCGI.

@Test
public void testHashNestedCGI() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfset a.books = #CGI.user.books#>\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("GLOBAL_VAR", result.get(0).getMessageCode());
    assertEquals("CGI", result.get(0).getVariable());
    assertEquals(3, result.get(0).getLine());
}
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