Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNUSED_LOCAL_VARIABLE incompatible with cfquery #693

Open
jaredbeck opened this issue Oct 2, 2020 · 5 comments
Open

UNUSED_LOCAL_VARIABLE incompatible with cfquery #693

jaredbeck opened this issue Oct 2, 2020 · 5 comments

Comments

@jaredbeck
Copy link

jaredbeck commented Oct 2, 2020

EDIT: better example below

Possibly related to #657

@jaredbeck
Copy link
Author

jaredbeck commented Oct 2, 2020

A more complete example:

<cffunction name="f">
  <cfquery>
    <cfloop list="a,b,c" index="local.x">
      #x#
    </cfloop>
  </cfquery>
</cffunction>
Message code:UNUSED_LOCAL_VARIABLE
	File:redacted.cfm
	Column:11
	Line:3
		Message:Local variable x is not used in function f. Consider removing it.
		Variable:'x' in function: f
		Expression:x

@jaredbeck
Copy link
Author

For comparison, the following passes:

    <cfset var x = 0>
    <cfloop list="a,b,c" index="x">

@jaredbeck
Copy link
Author

To further simplify the example:

<cffunction name="f">
  <cfset var x = 0>
  <cfquery datasource="#request.app_datasource#">
    #x#
  </cfquery>
</cffunction>

It seems that using a variable in cfquery is not recognized.

@jaredbeck jaredbeck changed the title UNUSED_LOCAL_VARIABLE: False positive: cfloop index UNUSED_LOCAL_VARIABLE incompatible with cfquery Oct 2, 2020
@jaredbeck
Copy link
Author

This issue is very similar to #632. If it's helpful to you to combine them, @ryaneberly, please feel free to.

@CreativeNotice
Copy link

CreativeNotice commented Dec 31, 2020

Can confirm this happens when in script syntax as well. In this example, header will trigger the rule.

for( var header in requestHeaders ){
	cfhttpparam( type = 'header', name = header.name, value = header.value );
}

Also ocures when using cfhttp().

var fullURL = 'https://www.google.com/';
cfhttp( URL = fullURL, result = 'myResult' ){ ..... };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants