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

Complex if() freezes analysis #266

Closed
mpaluchowski opened this issue May 2, 2017 · 6 comments
Closed

Complex if() freezes analysis #266

mpaluchowski opened this issue May 2, 2017 · 6 comments
Labels

Comments

@mpaluchowski
Copy link
Contributor

Trying to analyze the following, rather complex, if() statement will freeze analysis. No error or anything, just hanging there until manually killed.

component {
  function foo() {
    if (keys[i] == sectionActionsName && !loadSectionFreeSkills && !loadSectionActions && !loadSectionActionsContact && !loadSectionActionsHistory && !loadSectionComment
        || keys[i] == sectionProfileName && !loadSectionProfile
        || keys[i] == sectionLanguagesName && !loadSectionLanguages
        || keys[i] == sectionExperienceWidgetName && !loadSectionProfile && !loadSectionExperience
        || keys[i] == sectionProfileName && !loadSectionProfile
        || keys[i] == sectionExperienceName && !loadSectionExperience
        || keys[i] == sectionSkillsName && !loadSectionSkills
        || keys[i] == sectionFreeSkillsName && !loadSectionFreeSkills
        || keys[i] == sectionFunctionsName && !loadSectionFunctions
        || keys[i] == sectionEducationName && !loadSectionEducation
        || keys[i] == sectionAttachmentName && !loadSectionAttachment
    ) {
        // do something
    }
  }
}
@jevans-gp
Copy link

that's terrible code, as a human i freeze reading it.

@mpaluchowski
Copy link
Contributor Author

You're saying CFLint freezes in horror when it encounters that piece of code? A linter with feelings. How advanced! ;-)

Of course, I agree. And I'd love to see CFLint have a rule for that, ie. "if() condition has more than 5|configurable branches. Simplify it." It just shouldn't freeze or break otherwise.

@ryaneberly
Copy link
Contributor

It's on the ANTLR parsing.
Does this problem happen with v 1.0.1? I wonder if the looser semi-colon handling is tying it in knots.

@mpaluchowski
Copy link
Contributor Author

1.0.1 behaves the same, and so does 1.0.0. Both freeze.

@ryaneberly
Copy link
Contributor

@mpaluchowski , Thanks for checking. That helps - so it's not the semi-colon handling. I'll try upgrading to antlr 4.7 before doing too much grammar debugging.

ryaneberly added a commit to cfparser/cfparser that referenced this issue Jun 17, 2017
@ryaneberly
Copy link
Contributor

This is fixed in cfparser 2.4.6 (coming to maven soon)

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

4 participants