cflint / CFLint

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

Argument appScope is not required and does not define a default value. #50

Closed laserbyte closed 9 years ago

laserbyte commented 9 years ago

I'm running the latest CFLint built from the source of the master branch. Here is my code from my Application.cfc.

<cffunction name="onSessionEnd" returnType="void" output="false">
    <cfargument name="sessionScope" type="struct" required="true">
    <cfargument name="appScope" type="struct" required="false">
</cffunction>
ryaneberly commented 9 years ago

You are saying CFLint is not firing a ARG_DEFAULT_MISSING message, correct?

laserbyte commented 9 years ago

Yes, apparently I misread the warning. As soon as I added a blank default the warning went away:

However from reading the documentation I'm not clear on what a reasonable default for the Application scope argument would be. http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d40.html In their examples they have it both ways but they don't say what a reasonable default should be.
ryaneberly commented 9 years ago

ARG_DEFAULT_MISSING is an attempt to help ensure your API doesn't do something unexpected when the caller doesn't pass all the arguments.

We could disable this rule for the onXXX callback functions in Application.cfc.

Especially given the example in the Adobe docs..

What do you think?

laserbyte commented 9 years ago

Honestly my preference would be to keep flagging the error, but just get some clarification from Adobe on what a reasonable default for the AppScope parameter actually is. Unfortunately the docs for 11 don't seem to be much better:

https://wikidocs.adobe.com/wiki/display/coldfusionen/onSessionEnd

ryaneberly commented 9 years ago

I agree with keeping the flag as is.

I would argue that you should just make it required="true", instead of trying to figure out what a good default value would be.

This is a callback function from the system, and the system probably is going to be sending that 2nd parameter all of the time. It's going to be consistent anyway.