Skip to content

Commit

Permalink
added test that checks for false positive on local variable used in q…
Browse files Browse the repository at this point in the history
…uery param #416
  • Loading branch information
justinmclean committed Aug 10, 2017
1 parent 9a008a9 commit c4624c4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/java/com/cflint/TestUnusedLocalVarChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,26 @@ public void testMultipleUnusedVarFunctionInTag() throws ParseException, IOExcept
assertEquals(7, result.get(2).getLine());
}


@Test
public void testUsedVarInQuaryParam() throws ParseException, IOException {
final String tagSrc = "<cfcomponent>\r\n"
+ "<cffunction name=\"changePassword\">\r\n"
+ "<cfscript>\r\n"
+ "var salt = createUUID();\r\n"
+ "var hash = hash(password & salt);\r\n"
+ "var update = \"\";\r\n"
+ "</cfscript>\r\n"
+ "<cfquery name=\"update\">\r\n"
+ "update logins\r\n"
+ "set hash = <cfqueryparam value=\"#hash#\" cfsqltype=\"CF_SQL_VARCHAR\">\r\n"
+ "</cfquery>\r\n"
+ "</cffunction>\r\n"
+ "</cfcomponent>";

cfBugs.process(tagSrc, "test");
final List<BugInfo> result = cfBugs.getBugs().getBugList().get("UNUSED_LOCAL_VARIABLE");
assertEquals(0, result.size());
}

}

0 comments on commit c4624c4

Please sign in to comment.