Search in sources :

Example 41 with CFLintResult

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

the class TestCFBugs_ArgsHint method testMissingHint.

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

Example 42 with CFLintResult

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

the class TestCFBugs_ArgsType method testMissingTypeNoTags.

@Test
public void testMissingTypeNoTags() throws CFLintScanException {
    final String cfcSrc = "component {\r\n" + "public void function test(arg1) {\r\n" + "}\r\n" + "}\r\n";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    final List<BugInfo> result = lintresult.getIssues().values().iterator().next();
    assertEquals(1, result.size());
    assertEquals("ARG_TYPE_MISSING", result.get(0).getMessageCode());
    assertEquals(2, result.get(0).getLine());
    assertEquals(Levels.WARNING, result.get(0).getSeverity());
    assertEquals("Argument arg1 is missing a type.", result.get(0).getMessage());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 43 with CFLintResult

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

the class TestCFBugs_ArgsUse method testVarAndArgs_Struct.

@Test
public void testVarAndArgs_Struct() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfargument name=\"page\" default=\"\">\r\n" + "	<cfset variables.instance.page = arguments.page />\r\n" + "</cffunction>\r\n" + "</cfcomponent>";
    CFLintResult lintresult = cfBugs.scan(cfcSrc, "test");
    assertEquals(lintresult.getIssues().toString(), 0, lintresult.getIssues().size());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 44 with CFLintResult

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

the class TestCFBugs_ArgsUse method testVarAndArgs_MixedUse_2x.

@Test
public void testVarAndArgs_MixedUse_2x() throws CFLintScanException {
    final String cfcSrc = "<cfcomponent>\r\n" + "<cffunction name=\"test\">\r\n" + "	<cfargument name=\"xyz\" default=\"\">\r\n" + "	<cfset xyz=123/>\r\n" + "	<cfset y=arguments.xyz/>\r\n" + "	<cfset z=arguments.xyz/>\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("ARG_VAR_MIXED", result.get(0).getMessageCode());
    assertEquals(5, result.get(0).getLine());
}
Also used : CFLintResult(com.cflint.api.CFLintResult) Test(org.junit.Test)

Example 45 with CFLintResult

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

the class TestCFBugs_ArgsUse method testVarAndArgs_Cfscript_OK.

@Test
public void testVarAndArgs_Cfscript_OK() throws CFLintScanException {
    final String cfcSrc = "component { \r\n" + "public void function foo(any arg1=\"\") { \r\n" + "arg1=123; \r\n" + "} \r\n" + "}";
    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