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

Doesn't seem to be checking missing_var on cfscript cfcs #186

Closed
aaronsnyder opened this issue Jul 28, 2016 · 5 comments
Closed

Doesn't seem to be checking missing_var on cfscript cfcs #186

aaronsnyder opened this issue Jul 28, 2016 · 5 comments

Comments

@aaronsnyder
Copy link

I've been using CFLint (running the jar directly) and am able to verify that it will find missing var's in standard .cfc files. However, when testing on a .cfc file that is entirely cfscript, it doesn't seem to find my missing var's.

Here's the command I'm running (in case it helps):

java -jar CFLint-0.7.3-all.jar -file /[webroot]/cfc/functions.cfc | grep -i 'missing_var'

I don't see anything in the docs that leads me to believe that cfscript isn't supported. Any thoughts on what I'm missing here?

CFLint version: 0.7.3

ryaneberly added a commit that referenced this issue Jul 29, 2016
@ryaneberly
Copy link
Contributor

It should work with pure cfscript components. I added a test to confirm that. It's working. Can you share the code snippet that doesn't flag the missing var?

@aaronsnyder
Copy link
Author

aaronsnyder commented Jul 30, 2016

Hey @ryaneberly, thanks for the quick reply!

After you confirmed that CFLint should infact be checking varscoping in CFSCRIPT CFCs, I set out to try to figure out why mine was being left out. I've built a test file that reflects the breaky parts of the CFC in my codebase.

After I found this, I thought, "well there's probably a better way for us to do that!", but nonetheless, having a method like poorlyWrittenFunction() in a CFC file seems to prevent CFLint from reporting any issues on anything else in that file. It's as if CFLint becomes distracted by the awful, and forgets why it's even there.

In my testing, it seems that all components of poorlyWrittenFunction() are required to reproduce the bug, hopefully this is helpful in diagnosing, should you decide to fix it.

Thanks!

Aaron

component {

    public void function leakMemory(leak_modifier) {
        leaky_variable = leak_modifier;
        leakier_variable = leaky_variable * 2;

        return leaky_variable * leakier_variable;
    }

    public void function poorlyWrittenFunction() {
        writeDump('
            <img style="width:100%;float:left;" src="#request.imagefolder#/#application.SiteInfo.site_foldername#/404.jpg">
        ');
    }
}

ryaneberly added a commit that referenced this issue Jul 30, 2016
@ryaneberly
Copy link
Contributor

Ok, there was a bug. The Jericho Parser sees a <img/> and assumes it has to parse CFML. I changed the code to parse cfscript if it finds a "component" ahead of that first "element" (or there are no elements at all -- which was supported by the old code).

@ryaneberly
Copy link
Contributor

Thanks for the great sample

@aaronsnyder
Copy link
Author

Awesome, thanks @ryaneberly!

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

No branches or pull requests

2 participants