CFLint
CFLint copied to clipboard
UNUSED_LOCAL_VARIABLE false positive with var used in closure function
var address = variables.addressService.getAddressById(
addressId = billingAddressId
);
addressColumns.each(function (addressColumn) {
variables['billing' & addressColumn] = address.find(addressColumn, '');
});
[cflint] UNUSED_LOCAL_VARIABLE: Local variable address is not used in function getBillingAddress. Consider removing it.
address
(has to be referenced in an unscoped way, as local would be the closure's local scope) is used in the closure function of the Array.each()
call.
Same applies for UNUSED_METHOD_ARGUMENT
I can reproduce this bug in version 1.4.1. Here's another example:
private array function groupings(){
var spr = super;
return memoize('2d_demo_groupings', function(){
var gs = spr.groupings();
// ...
Message code:UNUSED_LOCAL_VARIABLE
File:/Users/jared/redacted/redacted.cfc
Column:6
Line:38
Message:Local variable spr is not used in function groupings. Consider removing it.
Variable:'spr' in function: groupings
Expression:null