Skip to content

Commit

Permalink
517 fp (#566)
Browse files Browse the repository at this point in the history
* #517 added caller and thisTag scopes

* tests for #517

* #517
  • Loading branch information
ryaneberly authored May 6, 2018
1 parent 8ffff19 commit f17747b
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 7 deletions.
30 changes: 30 additions & 0 deletions src/main/java/com/cflint/CF.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,16 @@ public class CF {
*/
public static final String APPLICATION = "application";

/**
* CF scope application.
*/
public static final String FLASH= "flash";

/**
* CF scope attributes.
*/
public static final String ATTRIBUTES= "attributes";

/**
* CF scope cgi.
*/
Expand All @@ -415,11 +425,21 @@ public class CF {
*/
public static final String SERVER = "server";

/**
* CF scope thread.
*/
public static final String THREAD= "thread";

/**
* CF scope session.
*/
public static final String SESSION = "session";

/**
* CF scope super.
*/
public static final String SUPER = "super";

/**
* CF scope client.
*/
Expand All @@ -440,6 +460,16 @@ public class CF {
*/
public static final String LOCAL = "local";

/**
* CF scope thisTag.
*/
public static final String THISTAG = "thistag";

/**
* CF scope caller.
*/
public static final String CALLER = "caller";

/**
* CF scope this.
*/
Expand Down
27 changes: 20 additions & 7 deletions src/main/java/com/cflint/StackHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,26 @@ public class StackHandler {

public StackHandler() {
super();
excludes.add("VARIABLES");
excludes.add("ARGUMENTS");
excludes.add("SUPER");
excludes.add("SESSION");
excludes.add("APPLICATION");
excludes.add("THIS");
excludes.add("LOCAL");
//Scopes
excludes.add(CF.VARIABLES.toUpperCase());
excludes.add(CF.ARGUMENTS.toUpperCase());
excludes.add(CF.SUPER.toUpperCase());
excludes.add(CF.SESSION.toUpperCase());
excludes.add(CF.APPLICATION.toUpperCase());
excludes.add(CF.THIS.toUpperCase());
excludes.add(CF.LOCAL.toUpperCase());
excludes.add(CF.THISTAG.toUpperCase());
excludes.add(CF.CALLER.toUpperCase());
excludes.add(CF.ATTRIBUTES.toUpperCase());
excludes.add(CF.CGI.toUpperCase());
excludes.add(CF.CLIENT.toUpperCase());
excludes.add(CF.COOKIE.toUpperCase());
excludes.add(CF.FLASH.toUpperCase());
excludes.add(CF.FORM.toUpperCase());
excludes.add(CF.REQUEST.toUpperCase());
excludes.add(CF.SERVER.toUpperCase());
excludes.add(CF.THREAD.toUpperCase());
excludes.add(CF.URL.toUpperCase());
varStack.push(new Stack(""));
}

Expand Down
10 changes: 10 additions & 0 deletions src/test/resources/com/cflint/tests/VarScoper/fpositive/.cflintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"rule" : [ ],
"excludes" : [ ],
"includes" : [ {
"code" : "MISSING_VAR",
"messageText" : null,
"severity" : null
} ],
"inheritParent" : false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
component{
function foo(){
application.facebookSDK.facebookApp = new facebook.sdk.FacebookApp(
appId=application.config.FBPhotoEndpoint_APPID,
secretKey=application.config.FBPhotoEndpoint_SECRET_KEY,
apiVersion=application.config.FBPhotoEndpoint_Version);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 1515639111,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
component{
function foo(){
var oExpectation = new Expectation( spec=this, assertions=this.$assert, mockbox=this.$mockbox );
thread.closures = arguments.closures;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 1525480387,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
component{
function foo(resourceUri){
var httpRequest = new HTTP(
method = "get",
url = ("http://api.foo.com" & resourceUri),
charset = "utf-8"
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 1515639111,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
component{
function foo(resourceUri){
var httpRequest = new Http(method=arguments.method, url=variables.ENDPOINT & arguments.resourceUri, charset="utf-8", timeout=arguments.timeout, throwOnError=false, username=variables.something, password=variables.somethingelse, getAsBinary="never");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 1515639111,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}
11 changes: 11 additions & 0 deletions src/test/resources/com/cflint/tests/VarScoper/fpositive/mail.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
component{
function foo(mailBody){
var mailService=new mail(
to="...",
from="...",
subject="...",
type="HTML",
body=mailBody
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 1515639111,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
component{
function foo(){
var qGetSites = new Query(datasource="...", sql="...");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 1515639111,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
component{
void function setCallerVars(data, row, getRow, columnNames){
var currentRow=0;
var rowData = getRow(data, row, columnNames);
caller["currentRow"] = currentRow;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version" : "",
"timestamp" : 0,
"issues" : [ ],
"counts" : {
"totalFiles" : 0,
"totalLines" : 0,
"countByCode" : [ ],
"countBySeverity" : [ ]
}
}

0 comments on commit f17747b

Please sign in to comment.