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

#553 implemented. catch variables are no longer false flags #567

Merged
merged 1 commit into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,14 @@ private void process(final Element elem, final String space, final Context conte
scanElement(elem, context);
processStack(elem.getChildElements(), space + " ", context);
handler.pop();
} else if (elem.getName().equalsIgnoreCase(CF.CFCATCH)) {
scanElement(elem, context);
handler.push(CF.CFCATCH);
if(elem.getAttributeValue("name")!=null){
handler.addVariable(elem.getAttributeValue("name"));
}
processStack(elem.getChildElements(), space + " ", context);
handler.pop();
} else {
scanElement(elem, context);
for (final Entry<String, CFExpression> expression : unpackTagExpressions(elem).entrySet()) {
Expand Down Expand Up @@ -875,7 +883,12 @@ private void process(final CFScriptStatement expression, final Context context)
final CFTryCatchStatement cftry = (CFTryCatchStatement) expression;
process(cftry.getBody(), context);
for (final CFCatchStatement stmt : cftry.getCatchStatements()) {
handler.push(CF.CFCATCH);
if(stmt.getVariable()!=null){
handler.addVariable(stmt.getVariable().getName());
}
process(stmt.getCatchBody(), context);
handler.pop();
}
process(cftry.getFinallyStatement(), context);
} else if (expression instanceof CFReturnStatement) {
Expand Down
14 changes: 14 additions & 0 deletions src/test/resources/com/cflint/tests/VarScoper/553_catch.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
component {
public string function renderPage( required any page, required any docTree, required boolean edit ){
try {
var renderedPage = renderTemplate(
template = "templates/#_getPageLayoutFile( arguments.page )#.cfm"
, args = { page = arguments.page, docTree=arguments.docTree, edit=edit }
, helpers = "/builders/html/helpers"
);
} catch( any e ) {
e.additional.luceeDocsPageId = arguments.page.getid();
rethrow;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 1513437208,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<cfcomponent>
<cffunction name="foo">
<cftry>
<cfcatch name="e">
<cfset e.additional.luceeDocsPageId = 1/>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 1525483036,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}