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

MISSING_VAR not caught for undeclared struct #404

Closed
KamasamaK opened this issue Aug 4, 2017 · 9 comments
Closed

MISSING_VAR not caught for undeclared struct #404

KamasamaK opened this issue Aug 4, 2017 · 9 comments
Assignees
Labels
Milestone

Comments

@KamasamaK
Copy link
Collaborator

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;
@ryaneberly
Copy link
Contributor

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.

@KamasamaK
Copy link
Collaborator Author

@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.

@TheRealAgentK TheRealAgentK added this to the 1.3.0 milestone Aug 9, 2017
@ryaneberly
Copy link
Contributor

so we can close this one?

@KamasamaK
Copy link
Collaborator Author

KamasamaK commented Aug 17, 2017

@ryaneberly For what reason? I just checked the latest dev build and did not see this fixed. I also got a number of PLUGIN_ERROR reports, so it's possible something is breaking it if it's supposed to be fixed. But I notice you did not tag this issue in a commit, which you normally do.

@ryaneberly
Copy link
Contributor

@KamasamaK ,
Maybe I misunderstood. What are we fixing in this issue that is not covered in #406?

  Can you provide a little more info on the PLUGIN_ERRORs you are seeing?

@KamasamaK
Copy link
Collaborator Author

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.

@ryaneberly
Copy link
Contributor

Well said. Thanks @KamasamaK

ryaneberly added a commit that referenced this issue Aug 21, 2017
change one test results.  Add examples, and implement enhancement.
@ryaneberly
Copy link
Contributor

ryaneberly added a commit that referenced this issue Aug 24, 2017
* #404

change one test results.  Add examples, and implement enhancement.

* fix test

* fix test

* cleanup
@ryaneberly
Copy link
Contributor

@KamasamaK . This seems to be working per the tests added in 8680345

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

No branches or pull requests

3 participants