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_SEMI false positive in if/else #289

Closed
TheRealAgentK opened this issue Jun 7, 2017 · 10 comments
Closed

MISSING_SEMI false positive in if/else #289

TheRealAgentK opened this issue Jun 7, 2017 · 10 comments
Assignees
Labels

Comments

@TheRealAgentK
Copy link
Collaborator

TheRealAgentK commented Jun 7, 2017

<cfscript>
	a = false;
	b = "";

	if (isDefined("c") && d == "registration") {
		b = "e.f";
	}
	else if (structKeyExists(variables,'g') && variables.g) {
		b = "y.j";
		myFusebox.do("k.l");
	}
	else if (session.sf.get('n.m') == "p") {
		b = "l.k";
		session.sf.set('n.m',false);
	}
</cfscript>

Result:

<issue severity="ERROR" id="MISSING_SEMI" message="MISSING_SEMI" category="CFLint" abbrev="MS"><location file="/Users/kai/Documents/Code/....cfm" fileName="ppp.cfm" function="" column="1" line="8" message="End of statement(;) expected instead of else" variable=""><Expression><![CDATA[else]]></Expression></location>
</issue>
<issue severity="ERROR" id="MISSING_SEMI" message="MISSING_SEMI" category="CFLint" abbrev="MS"><location file="/Users/kai/Documents/Code/.....cfm" fileName="ppp.cfm" function="" column="14" line="10" message="End of statement(;) expected instead of (" variable=""><Expression><![CDATA[(]]></Expression></location>
</issue>

The offending lines are:

else if (structKeyExists(variables,'g') && variables.g) {

and

myFusebox.do("k.l");

@TheRealAgentK
Copy link
Collaborator Author

Trying to ignore the MISSING_SEMI here leads to the same issue as reported in #285.

I've tried to put

// cflint ignore:MISSING_SEMI on lines 8 and 10 to the right of the code - doesn't do anything.

Tried to put it above each of the offending/reported lines - doesn't do anything either.

@TheRealAgentK
Copy link
Collaborator Author

TheRealAgentK commented Jun 7, 2017

Interesting enough, putting

<!--- @CFLintIgnore MISSING_SEMI --->

above the <cfscript> tag doesn't help and it's still not being ignored.

@TheRealAgentK
Copy link
Collaborator Author

TheRealAgentK commented Jun 7, 2017

Ahh, actually the same file triggers this, too:

<issue severity="ERROR" id="PARSE_ERROR" message="PARSE_ERROR" category="CFLint" abbrev="PE"><location file="/Users/kai/Documents/Code/...cfm" fileName="act_processModalRules.cfm" function="" column="1" line="11" message="Unable to parse" variable=""><Expression><![CDATA[mismatched input '}' expecting WHILE]]></Expression></location>
</issue>

which now makes me think that the core of this whole issue might be that CFLint thinks

myFusebox.do("k.l");

is actually starting a do-while loop?

@ryaneberly
Copy link
Contributor

created this issue in the cfparser project
cfparser/cfparser#76

@ryaneberly
Copy link
Contributor

@TheRealAgentK . Yes, you are correct. Do is a reserved word. I am changing the parser to be aware of the differences between a member function call and an unqualified function call.

You could work around it today if you are able to rename your do() function.

@ryaneberly ryaneberly self-assigned this Jun 16, 2017
@ryaneberly
Copy link
Contributor

fixed in cfparser 2.4.6

@TheRealAgentK
Copy link
Collaborator Author

Wow, you've been on a roll! :) Will give all of your fixes and changes a good test against my offending code during the weekend.

Does cfparser get pulled into the cflint maven build automatically?

@ryaneberly
Copy link
Contributor

Thanks.

No, to get the parser fixes:
checkout and build cfparser locally, and then change the version of cfparser in the CFLint pom to 2.4.6.

or wait a week on those few, I'll push cfparser out to maven soon.

@TheRealAgentK
Copy link
Collaborator Author

I just built it locally and it seems to run fine with my local cfparser 2.4.6

I do get a message about ANTLR 4.6 vs 4.7 though when running cflint.

...
JSON Output false
HTML Output false
log4j:WARN No appenders could be found for logger (com.cflint.tools.CFLintFilter).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
ANTLR Tool version 4.6 used for code generation does not match the current runtime version 4.7
...

Have updated all references in the pom to Antlr 4.7 though.

@TheRealAgentK
Copy link
Collaborator Author

The MISSING_SEMI issue is actually working fine now with that myFusebox.do(), too :)

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

2 participants