Search in sources :

Example 6 with CFLintResult

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

the class TestArgumentNames method invalidCharsInNameScript.

@Test
public void invalidCharsInNameScript() throws CFLintScanException {
    final String scriptSrc = "component {\r\n" + "function test($name, 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_INVALID_NAME", result.get(0).getMessageCode());
    assertEquals(2, result.get(0).getLine());
    assertEquals("ARGUMENT_INVALID_NAME", result.get(1).getMessageCode());
    assertEquals(2, result.get(1).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 7 with CFLintResult

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

the class TestArgumentNames method nameHasPrefixOrPostfixTag.

@Test
public void nameHasPrefixOrPostfixTag() throws CFLintScanException {
    final String tagSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfargument name=\"sName\">\r\n" + "	<cfargument name=\"nameSt\">\r\n" + "	<cfargument name=\"oName\">\r\n" + "	<cfargument name=\"bOff\">\r\n" + "	<cfargument name=\"arrNames\">\r\n" + "	<cfargument name=\"thisName\">\r\n" + "	<cfargument name=\"myName\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(7, result.size());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(0).getMessageCode());
    assertEquals(3, result.get(0).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(1).getMessageCode());
    assertEquals(4, result.get(1).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(2).getMessageCode());
    assertEquals(5, result.get(2).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(3).getMessageCode());
    assertEquals(6, result.get(3).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(4).getMessageCode());
    assertEquals(7, result.get(4).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(5).getMessageCode());
    assertEquals(8, result.get(5).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(6).getMessageCode());
    assertEquals(9, result.get(6).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 8 with CFLintResult

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

the class TestArgumentNames method nameIsTemporyTag.

@Test
public void nameIsTemporyTag() throws CFLintScanException {
    final String tagSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfargument name=\"temp\">\r\n" + "	<cfargument name=\"obj\">\r\n" + "	<cfargument name=\"struct\">\r\n" + "	<cfargument name=\"tempName\">\r\n" + "	<cfargument name=\"nameObj\">\r\n" + "	<cfargument name=\"nameString\">\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(tagSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().get("ARGUMENT_IS_TEMPORARY");
    assertEquals(6, result.size());
    assertEquals("ARGUMENT_IS_TEMPORARY", result.get(0).getMessageCode());
    assertEquals(3, result.get(0).getLine());
    assertEquals("ARGUMENT_IS_TEMPORARY", result.get(1).getMessageCode());
    assertEquals(4, result.get(1).getLine());
    assertEquals("ARGUMENT_IS_TEMPORARY", result.get(2).getMessageCode());
    assertEquals(5, result.get(2).getLine());
    assertEquals("ARGUMENT_IS_TEMPORARY", result.get(3).getMessageCode());
    assertEquals(6, result.get(3).getLine());
    assertEquals("ARGUMENT_IS_TEMPORARY", result.get(4).getMessageCode());
    assertEquals(7, result.get(4).getLine());
    assertEquals("ARGUMENT_IS_TEMPORARY", result.get(5).getMessageCode());
    assertEquals(8, result.get(5).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 9 with CFLintResult

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

the class TestArgumentNames method nameTooLongScript.

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

Example 10 with CFLintResult

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

the class TestArgumentNames method nameHasPrefixOrPostfixScript.

@Test
public void nameHasPrefixOrPostfixScript() throws CFLintScanException {
    final String scriptSrc = "component {\r\n" + "function test(aName, nameSt, oName, bOff, arrNames, thisName, myName) {\r\n" + "}\r\n" + "}";
    CFLintResult lintresult = cfBugs.scan(scriptSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(7, result.size());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(0).getMessageCode());
    assertEquals(2, result.get(0).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(1).getMessageCode());
    assertEquals(2, result.get(1).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(2).getMessageCode());
    assertEquals(2, result.get(2).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(3).getMessageCode());
    assertEquals(2, result.get(3).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(4).getMessageCode());
    assertEquals(2, result.get(4).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(5).getMessageCode());
    assertEquals(2, result.get(5).getLine());
    assertEquals("ARGUMENT_HAS_PREFIX_OR_POSTFIX", result.get(6).getMessageCode());
    assertEquals(2, result.get(6).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