Search in sources :

Example 16 with CFLintResult

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

the class TestBooleanExpressionChecker method testIfBooleanExpressionInTag.

@Test
public void testIfBooleanExpressionInTag() throws CFLintScanException {
    final String tagSrc = "<cfif a and b is true>\r\n" + "<cfset c = 1>\r\n" + "<cfelseif a or b is false>\r\n" + "<cfset c = 2>\r\n" + "<cfelse>\r\n" + "<cfset c = 3>\r\n" + "</cfif>\r\n";
    CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(2, result.size());
    assertEquals("EXPLICIT_BOOLEAN_CHECK", result.get(0).getMessageCode());
    assertEquals(1, result.get(0).getLine());
    assertEquals("EXPLICIT_BOOLEAN_CHECK", result.get(1).getMessageCode());
    assertEquals(3, result.get(1).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 17 with CFLintResult

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

the class TestBooleanExpressionChecker method testReturnBooleanExpressionInTag.

@Test
public void testReturnBooleanExpressionInTag() throws CFLintScanException {
    final String tagSrc = "<cffunction name=\"test\">\r\n" + "<cfreturn (e and f) is true>\r\n" + "</cffunction>";
    CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("EXPLICIT_BOOLEAN_CHECK", result.get(0).getMessageCode());
    assertEquals(2, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 18 with CFLintResult

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

the class TestCFBugs method testSimpleCFQUERYIssue30b_OK.

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

Example 19 with CFLintResult

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

the class TestCFBugs method testMissingSemiTag2.

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

Example 20 with CFLintResult

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

the class TestCFBugs method testSimpleCFQUERYNested.

@Test
public void testSimpleCFQUERYNested() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfoutput query=\"q123\">\r\n" + "	<cfset var y=123/>\r\n" + "	<cfoutput>#y#</cfoutput>\r\n" + "	</cfoutput>\r\n" + "</cffunction>\r\n" + "/<cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("NESTED_CFOUTPUT", result.get(0).getMessageCode());
    assertEquals(5, 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