cflint / CFLint

Static code analysis for CFML (a linter)
BSD 3-Clause "New" or "Revised" License
173 stars 84 forks source link

MISSING_VAR in CFLOOP index #413

Closed bardware closed 7 years ago

bardware commented 7 years ago

I have the following Coldfusion code and invoke CFLint like cflint.bat -file c:\folder\x.cfm -stdout -json from latest git checkout (1.2 release)

I expect 3 missing vars: xxx, strSel and idx. CFLint only lists two, idx is not regarded missing a var

<cffunction name="timePicker" returntype="string" hint="returns select" output="false">

    <cfsavecontent variable="strSel"><cfoutput>
        <select>
            <cfloop from="0" to="23" index="idx">
                <cfset xxx = NumberFormat(idx, "00")>
                <option value="#xxx#" <cfif xxx EQ 1>selected="selected"</cfif> >#xxx#</option>
            </cfloop>
        </select>
    </cfoutput></cfsavecontent>

    <cfreturn strSel>
</cffunction>
TheRealAgentK commented 7 years ago

Hey @bardware - is that on ACF or Lucee?

@ryaneberly - this issue looks like as if it's related to what Harry recently reported and where we compiled that list of tag attributes to look for. Was cfloop/index maybe missed in there?

ryaneberly commented 7 years ago

relates (a bit) to https://github.com/cflint/CFLint/issues/339

bardware commented 7 years ago

is that on ACF or Lucee

I'm on ACF

ryaneberly commented 7 years ago

ah. this is good... the related issue https://github.com/cflint/CFLint/issues/339 dealt with the issue within the unusedvar plugin. Parsing these tag attributes needs to be moved up to the framework level.

ryaneberly commented 7 years ago

This particular example is fixed, but fixing the concept of handling all variables created by CFML tags is deeper. I'm leaving this open, and the final fix will depend on some cfparser/cfdictionary changes.

ryaneberly commented 7 years ago

This is TCO.