Skip to content

Commit

Permalink
#553 implemented. catch variables are no longer false flags
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed May 5, 2018
1 parent 2957314 commit c7134bc
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
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" : [ ]
}
}

0 comments on commit c7134bc

Please sign in to comment.