Search in sources :

Example 91 with CFLintResult

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

the class TestCFBugs_TooManyArguments method testLargeNumberScriptBased.

@Test
public void testLargeNumberScriptBased() throws CFLintScanException {
    final String cfcSrc = "component {\r\n" + "public void function someFunction(argumentOne, argumentTwo, argumentThree," + "argumentFour, argumentFive, argumentSix, argumentSeven," + "argumentEight, argumentNine, intargumentTen, argumentEleven) {\r\n" + "	var a = 1;\r\n" + "}\r\n" + "}";
    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());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 92 with CFLintResult

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

the class TestCFBugs_VarScoper method testCFProcParam_InOut.

@Test
public void testCFProcParam_InOut() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "   <cfset var yy=\"\"/>\r\n" + "	<cfstoredproc name=\"yy\" >\r\n" + "	   <cfprocparam variable=\"xx\" type=\"inout\">\r\n" + "	</cfstoredproc>\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    assertEquals(1, lintresult.getIssues().size());
    List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("MISSING_VAR", result.get(0).getMessageCode());
    assertEquals("xx", result.get(0).getVariable());
    assertEquals(5, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 93 with CFLintResult

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

the class TestCFBugs_VarScoper method testScript_UnVard.

@Test
public void testScript_UnVard() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfscript>\r\n" + "   yy = 123;\r\n" + "	</cfscript>\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    assertEquals(1, lintresult.getIssues().size());
    List<BugInfo> result = lintresult.getIssues().get("MISSING_VAR");
    assertEquals(1, result.size());
    assertEquals("MISSING_VAR", result.get(0).getMessageCode());
    assertEquals("yy", result.get(0).getVariable());
    assertEquals(4, result.get(0).getLine());
    assertEquals(4, result.get(0).getLine());
    assertEquals(Levels.ERROR, result.get(0).getSeverity());
    assertEquals("Variable yy is not declared with a var statement.", result.get(0).getMessage());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 94 with CFLintResult

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

the class TestCFBugs_VarScoper method testCFFeed_Read_Vard.

// @Test
// public void testCFProcParam_In() throws CFLintScanException{
// final String cfcSrc = "<cfcomponent>\r\n" +
// "<cffunction name=\"test\">\r\n" +
// " <cfset var yy=\"\"/>\r\n" +
// " <cfstoredproc name=\"yy\" >\r\n" +
// " <cfprocparam variable=\"xx\" type=\"in\">\r\n" +
// " </cfstoredproc>\r\n" +
// "</cffunction>\r\n" +
// "</cfcomponent>";
// CFLintResult lintresult = cfBugs.scan(cfcSrc,"test");
// assertEquals(0,lintresult.getIssues().size());
// }
@Test
public void testCFFeed_Read_Vard() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "   <cfset var yy=\"\"/>\r\n" + "	<cffeed query=\"yy\" action=\"read\">\r\n" + "	</cffeed>\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 95 with CFLintResult

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

the class TestCFBugs_VarScoper method testScript_UnVard_ArrayFalsePositive.

@Test
public void testScript_UnVard_ArrayFalsePositive() throws CFLintScanException {
    final String cfcSrc = "<cffunction name=\"x\"><cfset var myRet = [] />\n" + "\n" + "<cfstoredproc>\n" + "   <cfprocresult name=\"myRet[1]\" resultset=\"1\" />\n" + "   <cfprocresult name=\"myRet[2]\" resultset=\"2\" />\n" + "   <cfprocresult name=\"myRet[3]\" resultset=\"3\" />\n" + "</cfstoredproc></cffunction>";
    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