CFLint icon indicating copy to clipboard operation
CFLint copied to clipboard

UNUSED_METHOD_ARGUMENT false positive

Open timbeadle opened this issue 6 years ago • 7 comments

I'm getting this false positive using CFLint 1.4.0.

public boolean function getAPIVersion(
	required numeric requestedAPIVersion
) cachedwithin=createTimeSpan(1,0,0,0) {
	return (variables.availableAPIVersions.find(arguments.requestedAPIVersion) > 0) ?
		arguments.requestedAPIVersion :
		variables.availableAPIVersions[1];
}

[cflint] UNUSED_METHOD_ARGUMENT: Argument requestedapiversion is not used in function. Consider removing it.

timbeadle avatar Jun 01 '18 08:06 timbeadle

CFParser is not parsing the cachedwithin=createTimeSpan(1,0,0,0)

phrase correctly.

ryaneberly avatar Oct 09 '18 00:10 ryaneberly

reference https://github.com/cfparser/cfparser/issues/106

ryaneberly avatar Oct 09 '18 00:10 ryaneberly

@ryaneberly Good spot. I still get the false positive when there is no cachedWithin statement, though.

timbeadle avatar Oct 16 '18 07:10 timbeadle

fixed in dev. added a test to cover this

ryaneberly avatar Sep 15 '19 03:09 ryaneberly

@ryaneberly The expected test result doesn't seem right. Shouldn't bar be reported for UNUSED_METHOD_ARGUMENT?

KamasamaK avatar Sep 15 '19 03:09 KamasamaK

I've just tested on the latest snapshot, and even though the test in ReturnArg_573.cfc is fine, the function in the opening post here is still reporting the issue.

KamasamaK avatar Sep 15 '19 14:09 KamasamaK

Good point. @KamasamaK . Turns out it works if ) cachedwithin=createTimeSpan(1,0,0,0) returnformat="json"{

i.e. createTimespan() is not the last function qualifier.
reopening https://github.com/cfparser/cfparser/issues/106 and moving this to 1.6.0

ryaneberly avatar Sep 17 '19 02:09 ryaneberly