CFLint
CFLint copied to clipboard
Inconsistent local variable detection?
Here’s a tiny component to demonstrate what I consider to be an inconsistency in CFLint.
<cfcomponent name="CFLintTest" output="false" hint="A testcase for CFLint." >
<cffunction name="testLocalVar" returntype="void" access="public" output="false" hint="Testing...">
<cfset var someoutput = "" />
<cfexecute name="test.exe" variable="someoutput" timeout="10" />
</cffunction>
<cfcomponent>
In this form, CFLint will complain with this message “Local variable someoutput is not used in function testLocalVariable. Consider removing it ( UNUSED_LOCAL_VARIABLE )
”. OK, let’s do that.
<cfcomponent name="CFLintTest" output="false" hint="A testcase for CFLint." >
<cffunction name="testLocalVar" returntype="void" access="public" output="false" hint="Testing...">
<cfexecute name="test.exe" variable="someoutput" timeout="10" />
</cffunction>
<cfcomponent>
But when you delete the line that defines the local variable, you’ll get another error message, saying “Variable someoutput is not declared with a var statement ( MISSING_VAR )
”.
So in the second situation it will detect the fact that ‘someoutput’ is a local variable, while that’s not the case in the first. Strange, yes. A bug ? Possibly…