Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Dec 20, 2017
1 parent ebe6510 commit 1665aa6
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import cfml.parsing.cfscript.script.CFScriptStatement;
import cfml.parsing.cfscript.script.CFSwitchStatement;
import cfml.parsing.cfscript.script.CFTryCatchStatement;
import cfml.parsing.cfscript.script.CFWhileStatement;
import cfml.parsing.reporting.ArrayErrorListener;
import cfml.parsing.reporting.IErrorReporter;
import cfml.parsing.reporting.ParseException;
Expand Down Expand Up @@ -812,6 +813,10 @@ private void process(final CFScriptStatement expression, final Context context)
process(((CFForStatement) expression).getCond(), elem, context);
process(((CFForStatement) expression).getNext(), elem, context);
process(((CFForStatement) expression).getBody(), context);
} else if (expression instanceof CFWhileStatement) {
scanExpression(expression, context, elem);
process(((CFWhileStatement) expression).getCond(), elem, context);
process(((CFWhileStatement) expression).getBody(), context);
} else if (expression instanceof CFForInStatement) {
scanExpression(expression, context, elem);
final Context forInitContext = context.subContext(elem);
Expand Down
17 changes: 17 additions & 0 deletions src/test/resources/com/cflint/tests/UnusedVariable/while_465.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
component{
function safetext(text) {
var obracket = find("<",theText);
var badTag = "";
var nextStart = "";
while(obracket){
badTag = REFindNoCase();
if(badTag.pos[1]){
nextStart = badTag.pos[1] + badTag.len[1];
}
else{
nextStart = obracket + 1;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"version" : "",
"timestamp" : 1513779574,
"issues" : [ {
"severity" : "INFO",
"id" : "UNUSED_LOCAL_VARIABLE",
"message" : "UNUSED_LOCAL_VARIABLE",
"category" : "CFLINT",
"abbrev" : "UL",
"locations" : [ {
"file" : "src\\test\\resources\\com\\cflint\\tests\\UnusedVariable\\while_465.cfc",
"fileName" : "while_465.cfc",
"function" : "safetext",
"column" : 8,
"line" : 3,
"message" : "Local variable obracket is not used in function safetext, consider removing it.",
"variable" : "obracket",
"expression" : ""
} ]
}, {
"severity" : "INFO",
"id" : "UNUSED_LOCAL_VARIABLE",
"message" : "UNUSED_LOCAL_VARIABLE",
"category" : "CFLINT",
"abbrev" : "UL",
"locations" : [ {
"file" : "src\\test\\resources\\com\\cflint\\tests\\UnusedVariable\\while_465.cfc",
"fileName" : "while_465.cfc",
"function" : "safetext",
"column" : 8,
"line" : 4,
"message" : "Local variable badTag is not used in function safetext, consider removing it.",
"variable" : "badTag",
"expression" : ""
} ]
}, {
"severity" : "INFO",
"id" : "UNUSED_LOCAL_VARIABLE",
"message" : "UNUSED_LOCAL_VARIABLE",
"category" : "CFLINT",
"abbrev" : "UL",
"locations" : [ {
"file" : "src\\test\\resources\\com\\cflint\\tests\\UnusedVariable\\while_465.cfc",
"fileName" : "while_465.cfc",
"function" : "safetext",
"column" : 8,
"line" : 5,
"message" : "Local variable nextStart is not used in function safetext, consider removing it.",
"variable" : "nextStart",
"expression" : ""
} ]
} ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ {
"code" : "UNUSED_LOCAL_VARIABLE",
"count" : 3
} ],
"countBySeverity" : [ {
"severity" : "INFO",
"count" : 3
} ]
}
}

0 comments on commit 1665aa6

Please sign in to comment.