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
MISSING_VAR not caught for undeclared struct #404
Comments
Wow, I didn't even know that was legitimate CF code. Seems to cross the line into territory that is too forgiving of bad coding :). Definitely worth linting. |
@ryaneberly I agree, and that should probably be its own rule so I've made a proposal in Issue #406. However, this rule should only be concerned with catching variables not declared in the local scope. |
so we can close this one? |
@ryaneberly For what reason? I just checked the latest |
@KamasamaK ,
|
As I said in my initial response, they have different purposes. That other rule is just recommending that you declare a variable as a struct or array type before using it with the dot or array notation. If they carry out that recommendation, then the lack of local scoping will be caught by MISSING_VAR as it is now. But they may choose to ignore or exclude it. There might be people who run CFLint and only include the MISSING_VAR rule because that's all they care about. While I wouldn't recommend using a struct or array without a type declaration, it is valid CFML and this rule should report those variables if they are not local scoped. |
Well said. Thanks @KamasamaK |
* #404 change one test results. Add examples, and implement enhancement. * fix test * fix test * cleanup
@KamasamaK . This seems to be working per the tests added in 8680345 |
Using a structure without first declaring it as a struct does not trigger this rule. Below are some examples of first use within a function.
Reported:
<cfset tokenizedAddress = {}>
tokenizedAddress = {};
Unreported:
<cfset tokenizedAddress.streetName = streetName>
tokenizedAddress.streetName = streetName;
<cfset tokenizedAddress["streetName"] = streetName>
tokenizedAddress["streetName"] = streetName;
The text was updated successfully, but these errors were encountered: