Search in sources :

Example 1 with CFLintResult

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

the class TestArgumentNames method testValidNamesTag.

@Test
public void testValidNamesTag() throws CFLintScanException {
    final String tagSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfargument name=\"first_name\">\r\n" + "	<cfargument name=\"firstname\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(tagSrc, "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 2 with CFLintResult

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

the class TestArgumentNames method testValidNamesScript.

@Test
public void testValidNamesScript() throws CFLintScanException {
    final String scriptSrc = "component {\r\n" + "function test(firstName, first_name, firstname) {\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 3 with CFLintResult

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

the class TestArgumentNames method nameTooLongTag.

@Test
public void nameTooLongTag() throws CFLintScanException {
    final String tagSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfargument name=\"isaveryveryverylongargumentname\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("ARGUMENT_TOO_LONG", result.get(0).getMessageCode());
    assertEquals(3, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 4 with CFLintResult

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

the class TestArgumentNames method nameEndsInNumberTag.

@Test
public void nameEndsInNumberTag() throws CFLintScanException {
    final String tagSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfargument name=\"name_1\">\r\n" + "	<cfargument name=\"name2\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(2, result.size());
    assertEquals("ARGUMENT_INVALID_NAME", result.get(0).getMessageCode());
    assertEquals(tagSrc.indexOf("name_1"), result.get(0).getOffset());
    assertEquals(3, result.get(0).getLine());
    assertEquals(3, result.get(0).getLine());
    assertEquals("ARGUMENT_INVALID_NAME", result.get(1).getMessageCode());
    assertEquals(tagSrc.indexOf("name2"), result.get(1).getOffset());
    assertEquals(4, result.get(1).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 5 with CFLintResult

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

the class TestArgumentNames method testUpercaseNameScript.

@Test
public void testUpercaseNameScript() throws CFLintScanException {
    final String scriptSrc = "component {\r\n" + "function test(FIRSTNAME, LAST_NAME) {\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_ALLCAPS_NAME", result.get(0).getMessageCode());
    assertEquals(2, result.get(0).getLine());
    assertEquals("ARGUMENT_ALLCAPS_NAME", result.get(1).getMessageCode());
    assertEquals(2, result.get(1).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