Search in sources :

Example 11 with CFLintResult

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

the class TestArgumentNames method nameTooShortScript.

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

Example 12 with CFLintResult

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

the class TestArrayNewChecker method testArrayNewMultiDimentionInScript.

@Test
public void testArrayNewMultiDimentionInScript() throws CFLintScanException {
    final String scriptSrc = "<cfscript>\r\n" + "var a = 23;\r\n" + "var b = arrayNew(3);\r\n" + "</cfscript>";
    CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
    assertEquals(0, lintresult.getIssues().size());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 13 with CFLintResult

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

the class TestArrayNewChecker method testArrayNewInTag.

@Test
public void testArrayNewInTag() throws CFLintScanException {
    final String tagSrc = "<cfset a = 23>\r\n" + "<cfset b = arrayNew(1)>";
    CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("AVOID_USING_ARRAYNEW", result.get(0).getMessageCode());
    assertEquals(2, result.get(0).getLine());
    assertEquals(Levels.INFO, result.get(0).getSeverity());
    assertEquals("Use implict array construction instead (= []).", result.get(0).getMessage());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 14 with CFLintResult

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

the class TestBooleanExpressionChecker method testReturnBooleanExpressionInScript.

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

Example 15 with CFLintResult

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

the class TestBooleanExpressionChecker method testSetBooleanExpressionInScript.

@Test
public void testSetBooleanExpressionInScript() throws CFLintScanException {
    final String scriptSrc = "<cfscript>\r\n" + "x = (a && b) == true;\r\n" + "</cfscript>";
    CFLintResult lintresult = cfBugs.scan(scriptSrc, "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)

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