forked from mschierberl/varscoper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testCaseCFC.cfc
905 lines (666 loc) · 24.8 KB
/
testCaseCFC.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
<!--- Problem Files --->
<!---
--->
<cfcomponent hint="I am the worst written CFC ever, my vars are horribly scoped">
<cfset variables.fooGlobalVar = "blah">
<cffunction name="comment_vars" hint="Handles false negatives for commented code, when var statements are commented out">
<!--- <cfset var foo = "bar" >--->
<cfset foo = "bar">
<cfreturn 1>
</cffunction>
<cffunction name="falsePositive_comments" hint="MINOR: returns a false positive when commented code has an unscoped variable">
<cfreturn 0>
<!--- <cfset withinComments = ""> --->
</cffunction>
<cffunction name="exportResults" access="remote" output="true" returntype="any">
<cfargument name="lockname" default="foo" />
<cfreturn 0>
<cfdocument filename="#ExpandPath('.')#\#arguments.lockName#.pdf" format="PDF">
Test case for var scoper
</cfdocument>
</cffunction>
<cffunction name="attributes" >
<cfset attributes = "foo" />
<cfreturn 1>
</cffunction>
<cffunction name="varNoSpace" hint="var statements with CR or tabs">
<cfset var AccountWhereClause = "" />
<cfset var
another = "" />
<cfreturn 0 />
</cffunction>
<cffunction name="farcry_script" hint="colon in struct key - discovered in farcry farcry/core/packages/farcry/rss.cfc parseRssDate()">
<cfreturn 0>
<cfset var stItem = structNew() />
<cfscript>
stItem['dc:date'] = "";
</cfscript>
</cffunction>
<cffunction name="another_farcry" hint="discovered in farcry/core/packages/farcry/stats.cfc getUserOs()">
<cfscript>
return 0;
var user_agent = '';
var os = "Mac";
if (findNoCase("68",user_agent))
os = os & " 68k";
else if (findNoCase("os x",user_agent))
os = os & " OSX";
else if (findNoCase("ppc",user_agent))
os = os & " PPC";
</cfscript>
</cffunction>
<cffunction name="farcry_sql" hint="discovered this in farcry alterType.cfc addProperty()">
<cfargument name="typename" required="true" default="foo">
<cfargument name="srcColumn" required="true" default="foo">
<cfargument name="srcColumnType" required="true" default="foo">
<cfargument name="bNull" required="false" default="true">
<cfargument name="stDefault" required="false" default="">
<cfargument name="dsn" default="foo" required="false">
<cfargument name="dbtype" default="mssql" required="false">
<cfset var sql = "" />
<cfreturn 0 />
<cfscript>
switch(arguments.dbtype){
case "postgresql":
{
if (Len(arguments.stDefault)) sql = sql & "; ALTER TABLE #application.dbowner##arguments.typename# ALTER COLUMN #arguments.srcColumn# set default '#stDefault#'; UPDATE #application.dbowner##arguments.typename# SET #arguments.srcColumn# = '#stDefault#'";
break;
}
case "mysql":
{
if (arguments.bNull) sql = sql & "NULL";
else sql = sql & "NOT NULL";
if (Len(arguments.stDefault) OR NOT arguments.bNull) sql = sql & " DEFAULT '#stDefault#'";
break;
}
}
</cfscript>
</cffunction>
<cffunction name="listDiff" hint="discovered this in mangoBlog appears to be caused by the * before Compares ">
<cfargument name="list1" default="foo">
<cfargument name="list2" default="bar">
<cfreturn 0 />
<cfscript>
/**
* Compares two lists and returns the elements that do not appear in both lists.
*/
var delimiters = ",";
delimiters = arguments[3];
</cfscript>
</cffunction>
<cffunction name="cfdocument" access="remote" output="true" returntype="any">
<cfargument name="lockname" default="foo" />
<cfset var scoped = '' />
<cfreturn 0/>
<cfdocument filename="#ExpandPath('.')#\#arguments.lockName#.pdf" format="PDF">
Test case for var scoper
</cfdocument>
<cfdocument name="scoped" fileName='unscoped' format="PDF" />
<cfdocument fileName="unscoped" name='scoped' format="PDF" />
</cffunction>
<cffunction name="issue_30" hint="500 error only in Open BD (<a href='http://varscoper.riaforge.org/index.cfm?event=page.issue&issueid=5599A48F-E8BF-9CE6-EACFB8EBAA9EAFAD' target='_new'>issue 30</a>)">
<cfset var blah = ""/>
<cfreturn 0>
<cfprocparam cfsqltype ="CF_SQL_BIT" variable="blah" type="out" />
</cffunction>
<cffunction name="issue_26" hint="this throws a 500 error, but only in open BD">
<cfargument name="pattern" required="false" default="foo"/>
<cfargument name="text" required="false" default="foo"/>
<cfset var partIndex = -1 />
<cfset var nextAsteriskLoc = 0/>
<cfset var part = "" />
<cfloop condition="partIndex NEQ -1">
<cfif doMatch(arguments.pattern.substring(nextAsteriskLoc), arguments.text.substring(partIndex + part.length()))>
<cfreturn true />
</cfif>
<cfset partIndex = arguments.text.indexOf(part, partIndex + 1) />
</cfloop>
<cfreturn 0 />
</cffunction>
<cffunction name="doMatch" hint="this is a helper function for issue_26">
<cfreturn 0>
</cffunction>
<cffunction name="issue_25" hint="(<a href='http://varscoper.riaforge.org/index.cfm?event=page.issue&issueid=011F3BEB-BD54-462E-CA2B0E99C88BFA86' target='_new'>issue 25</a>)">
<cfset var local = structNew() />
<cfset local.searchterm = "foo" />
<cfset local.counter = "1" />
<cfscript>
//init fields
local.fieldcount = 0;
local.searchstring = "";
local.startBracketCount = 0;
local.endBracketCount = 0;
searchportion = Find('"', Mid(local.searchTerm, local.counter, Len(local.searchTerm))) - 1;
</cfscript>
<cfreturn 1>
</cffunction>
<cffunction name="cfthread_not_ok" access="public"
hint="This will fail if thread scope is ignored, but there is another unscoped variable named thread (<a target='_new' href='http://varscoper.riaforge.org/index.cfm?event=page.issue&issueid=D7C2874C-AA93-FE66-5B1B25C48568EB4C'>issue 24</a>)" >
<cfset thread.foo = "">
<cfreturn 1 />
</cffunction>
<cffunction name="cfthread_ok" access="public" hint="thread is an ok scope if it's within a cfthread tag (<a target='_new' href='http://varscoper.riaforge.org/index.cfm?event=page.issue&issueid=D7C2874C-AA93-FE66-5B1B25C48568EB4C'>issue 24</a>)" >
<cfthread name="foo">
<cfset thread.foo = "">
</cfthread>
<cfreturn 0 />
</cffunction>
<cffunction name="issue_27" access="public" hint="check to make sure username and name can both be used in cfftp">
<cfset var ftpName = "" />
<cftry>
<cfftp username="notBadVar" name="ftpName" password="password" action="open" server="localhost" stoponerror="false" >
<cfcatch>
</cfcatch>
</cftry>
<cfreturn 0 />
</cffunction>
<cffunction name="issue_28" access="public" hint="Mix cfscript with tag cfset gives false positive">
<cfscript>
var myvar = "";
</cfscript>
<cfset myvar = "myvalue" />
<cfreturn 0 />
</cffunction>
<cffunction name="simpleVarTestCF9" hint="ability to set var anywhere in function in CF9 (<a href='http://varscoper.riaforge.org/index.cfm?event=page.issue&issueid=07CA8A2F-C453-C7C1-D8778CDDED8E85C1' target='_new'>enhancement 29</a>)">
<cfset badSimpleVar ="bar">
<CFSET badSimpleVar2 = "">
<cfSet correctSimpleVar3 ="bar">
<cfset var correctSimpleVar4 = "" />
<cfset correctSimpleVar4 = "">
<cfset var correctSimpleVar3 = "" />
<cfreturn 2>
</cffunction>
<cffunction name="simpleScriptCF9" hint="ability to set var anywhere in function in CF9 (<a href='http://varscoper.riaforge.org/index.cfm?event=page.issue&issueid=07CA8A2F-C453-C7C1-D8778CDDED8E85C1' target='_new'>enhancement 29</a>)">
<cfset correctSimpleVar ="bar">
<CFSET correctSimpleVar2 = "">
<cfSet correctSimpleVar3 ="bar">
<cfscript>
var correctSimpleVar4 = "" ;
correctSimpleVar4 = "";
var correctSimpleVar3 = "";
</cfscript>
<cfreturn 3>
</cffunction>
<cffunction name="localTestCF9" hint="support for LOCAL scope in CF9 (<a href='http://varscoper.riaforge.org/index.cfm?event=page.issue&issueid=07CA8A2F-C453-C7C1-D8778CDDED8E85C1' target='_new'>enhancement 29</a>)">
<cfset LOCAL.correctSimpleVar = ""/>
<cfset correctSimpleVar ="bar">
<CFSET correctSimpleVar2 = "">
<cfSet correctSimpleVar3 ="bar">
<cfset LOCAL.correctSimpleVar3 = "" />
<cfset correctSimpleVar3 = "">
<cfreturn 1>
</cffunction>
<cffunction name="issue_22">
<cfargument name="ChartData" type="any" />
<cfset var local=structnew() />
<cfreturn 0>
<cfsilent>
<cfscript>
local.DefaultFormat = variables.chartConfig.getChartFormat(); // can be: flash, png, jpg
local.MaxCategories = variables.chartConfig.getMaxCategories(); // maximum number of x-axis categories
local.Format=variables.chartConfig.getChartFormat( arguments.ChartData.format );
local.SeriesPlacement = variables.ChartConfig.getSeriesPlacement(); // can be: cluster, stacked, percent
local.ChartWidth = variables.chartConfig.getChartWidth(); // integer width in px
local.ChartHeight = variables.chartConfig.getChartHeight(); // integer height in px
local.SeriesArray = arguments.ChartData.SeriesArray;
local.ScaleFrom = arguments.ChartData.ScaleFrom; // numerical value or empty string for auto scaling
local.ScaleTo = arguments.ChartData.ScaleTo; // numerical value or empty string for auto scaling
local.ChartStyleType=arguments.ChartData.chartStyleType;
local.showLegend=arguments.ChartData.showLegend;
local.LabelFormat=arguments.ChartData.LabelFormat;
local.ChartStyle=arguments.ChartData.ChartStyle;
local.SortXAxis=arguments.ChartData.SortXAxis;
if( fileExists( expandPath(variables.chartConfig.getDefaultChartStylePath() & local.ChartStyle ) ) IS false){
local.ChartStyle = variables.chartConfig.getDefaultChartStyle();
}
</cfscript>
</cfsilent>
<cfreturn 0 />
</cffunction>
<cffunction name="cfscript_comments" access="public" hint="MINOR: This is an example where it returns false positives in comments in cfscript">
<cfscript>
var correctSimpleVar5 = ""; //comments after var
// var withinComments = "";
/* var withincomments2 = ""; */
/*
var withincomments3 = ""; /*
*/
</cfscript>
<cfreturn 3>
<cfscript>
withinComments = "foo";
withinComments2 = "foo";
withinComments3 = "foo";
</cfscript>
</cffunction>
<cffunction name="cfscript_comments_problems" hint="has a problem processing /* */">
<cfscript>
/*
*/
var row = 1;
row = '';
</cfscript>
<cfreturn 0>
</cffunction>
<cffunction name="cfscript_nested_comments" hint="has a problem processing /* */">
<cfscript>
/*
/*
*/
var row = 1;
/*
unscoped = '';
/*
*/
row = '';
</cfscript>
<cfreturn 0>
</cffunction>
<cffunction name="cfquery_order_a">
<cfset var a = structNew()>
<cfset a.name='admin'>
<cfset a.password='test'>
<cfreturn 1>
<cfquery name="emailExists" username="#a.name#" password="#a.password#" datasource="data">
SELECT email
FROM emails
</cfquery>
</cffunction>
<cffunction name="cfquery_order_b">
<cfset var a = structNew()>
<cfset a.name='admin'>
<cfset a.password='test'>
<cfreturn 1>
<cfquery username="#a.name#" password="#a.password#" name="emailExists" datasource="data">
SELECT email
FROM emails
</cfquery>
</cffunction>
<cffunction name="issue_21">
<cfreturn 1>
<cfquery username="#a.name#" password="#a.password#" name="emailExists" datasource="data">
</cfquery>
</cffunction>
<cffunction name="cfftp_variables">
<cfset var scopedFtp = "">
<cfset var ListDirs = "">
<cfreturn 1>
<!--- <cfftp
connection =""
action = "LISTDIR"
name = "ListDirs"
directory = "/"> --->
<cfftp
connection = "myConnection"
action="close"
transferMode = "binary"
result="scopedFtp"
>
<cfset cfftp.test = "" />
<cfset scopedFtp.test = "" />
<cfset listDirs.test = ""/>
</cffunction>
<cffunction name="issue_18">
<cfreturn 1>
<!--- http://varscoper.riaforge.org/index.cfm?event=page.issueedit&issueid=83600F2D-F568-1871-197DE915EF2AB2C6 --->
<cfset scope[getLoggingPath()].data = arrayConcat(data["emailLogger"].data, scope[getLoggingPath()].data) />
</cffunction>
<cffunction name="issue_17">
<cfreturn 0>
<cfloop condition="1 EQ 0">
</cfloop>
</cffunction>
<cffunction name="testVar_Issue_19">
<cfscript>
var testVar = true;
return 0;
//This does not work: says ") testVar" is not scoped.
if (testVar EQ "true")
testVar = false;
else
testVar = true;
//This does validate correctly.
if (testVar EQ "true") {
testVar = false;
}
else {
testVar = true;
}
</cfscript>
</cffunction>
<cffunction name="negative_TODO">
<cfreturn 0>
<cfset read(id=pkId,object=foo) />
</cffunction>
<cffunction name="TODO_cfscript_return">
<cfreturn 0>
<cfscript>
return newStruct(ok="false", errorMessage="!", sValidationMsg="#getCaseString(attr)#",
field="#stResult.fieldname#", rules="#stRules#", result="#stResult#");
</cfscript>
</cffunction>
<cffunction name="resolved_TODO">
<cfset var cfcatch = ''>
<cfreturn 1>
<!--- NOTE: this should return a violation even though we can't evaluate #i# at runtime --->
<!--- I'd like this in to indicate to the users that they might have an issue --->
<cfset "test#i#" = 1 />
</cffunction>
<cffunction name="falsepositive" >
<cfset var cfcatch = ''>
<cfreturn 1>
<!--- NOTE: this should return a violation even though we can't evaluate #i# at runtime --->
<!--- I'd like this in to indicate to the users that they might have an issue --->
<cfset "test#i#" = 1 />
</cffunction>
<cffunction name="resolved_TODO_BUGS">
<cfreturn 1>
<cfset unscoped = ''>
<cfscript>
someFunction();
</cfscript>
</cffunction>
<cffunction name="resolved_TODO_comments" output="false">
<cfset var outsideComments = "" />
<cfset var WithinComments = "" /> ---> <!--- Note, leave the extra trailing comment here, when we include the ability to strip comments it introduces problems in other functions --->
<cfreturn 0>
<!--- <cfset WithinComments = ""/> --->
</cffunction>
<cffunction name="transfer_example" >
<cfscript>
var table = '';
return 0;
return table & "." & object.getPropertyByName(arguments.condition.getProperty()).getColumn() & " = '" & arguments.condition.getValue() & "'";
</cfscript>
</cffunction>
<cffunction name="nested_brackets" access="public" hint="Quite unusual but has been seen on wild. aScopedArray1[aScopedArray2[1] + 1]">
<cfscript>
var aScopedArray1 = arrayNew(1);
var aScopedArray2 = arrayNew(1);
return 0;
aScopedArray1[1] = "Hello World";
aScopedArray2[1] = 1;
aScopedArray1[aScopedArray2[1] + 1] = "Foobar";
</cfscript>
</cffunction>
<cffunction name="semicolon_in_string" access="public" hint="Semicolon appears within a quoted string - sScoped = "&quotedString=value";">
<cfscript>
var sScoped = "";
return 0;
sScoped = "&quotedString=value";
</cfscript>
</cffunction>
<cffunction name="cfscript_with_dash">
<cfscript>
var LOCAL = StructNew();
return 0;
LOCAL.CSS[ "background-color" ] = "";
</cfscript>
</cffunction>
<cffunction name="cfscript_sFileName">
<cfscript>
var sFileName = "";
var stReturn = "";
return 0;
if (variables.oFileSystem.checkFilePath(sDestination&sFileName))
sFileName = variables.oFileSystem.getAlternativeFileName(sDestination,sFileName);
if (Compare(stUploadedFile.ServerFile,sFileName)) {
stReturn.bFileRenamed = true;
}
</cfscript>
</cffunction>
<cffunction name="cfscript_complex_for">
<!--- Note, this example was from harry, the //data was from an XMLParse in the var statement --->
<cfscript>
var length = len("//data");
return 1;
for (i=1; i lte ArrayLen(arrTables);i=i+1) {};
</cfscript>
</cffunction>
<cffunction name="cfscript_funny_chars">
<cfscript>
var iMail = find("@", '');
var notallowed = " ;:!$%/()=?*";
return 0;
</cfscript>
</cffunction>
<cffunction name="bug_4">
<cfset var proper = ''>
<cfreturn 1>
<cfscript>
url[getUrlPageIndicator()] = urlPageNo;
proper[getUrlPageIndicator()] = urlPageNo;
unscoped[getUrlPageIndicator()] = urlPageNo;
</cfscript>
</cffunction>
<cffunction name="simpleVarTest">
<cfset var correctSimpleVar = "" />
<cfset var correctSimpleVar2 = "" />
<CFsET var correctSimpleVar3 = "" />
<cfset VAR correctSimpleVar4 = "" />
<!--- This return value should be updated when the unit test case changes --->
<cfreturn 5>
<cfset correctSimpleVar ="bar">
<CFSET correctSimpleVar2 = "">
<cfSet correctSimpleVar3 ="bar">
<cfset correctSimpleVar4 = "">
<cfset unscopedSimpleVar ="">
<cfset unscoped.var2 ="" >
<cfset un_scopedvar3 = "" />
<cfset un_scopedvar4 = '' />
<cfset
unscopedVar5 = '' />
</cffunction>
<cffunction name="loopsTest">
<!--- This should find a problem with foo2 and foo4 --->
<cfset var correctIndexLoop = "" />
<cfset var correctItemLoop = "" />
<cfreturn 9>
<!--- This return value should be updated when the unit test case changes --->
<cfloop from="1" to="2" index="correctIndexLoop"></cfloop>
<cfloop from="1" to="2" index="unscopedIndexLoop1"></cfloop>
<cfloop from="1" to="2" index ="unscopedIndexLoop2"></cfloop>
<cfloop from="1" to="2" index= "unscopedIndexLoop3"></cfloop>
<cfloop from="1" to="2" index = "unscopedIndexLoop4"></cfloop>
<cfloop from='1' to='2' index='unscopedIndexLoop5'></cfloop>
<cfloop from='1' to='2'
index ='unscopedIndexLoop6'></cfloop>
<!--- NOTE: This currently isn't being found --->
<cfloop from='1' to='2' index=
'unscopedIndexLoop7'></cfloop>
<cfloop from='1' to='2' index = 'unscopedIndexLoop8'></cfloop>
<cfloop collection="foo" item="correctItemLoop"></cfloop>
<cfloop collection="foo" item="unscopedItemLoop1"></cfloop>
</cffunction>
<cffunction name="unVaredQueries">
<cfset var correctQuery1 = "" />
<!--- This is for unit test, update if test case changes --->
<cfreturn 3>
<cfquery name=qryNoName datasource="#blah#" >
</cfquery>
<cfquery name="correctQuery1" dbType="query"></cfquery>
<cfquery name="unScopedQuery1" dbType="query"></cfquery>
<cfquery dbType="query"
name= 'unScopedQuery2'>
</cfquery>
</cffunction>
<cffunction name="structVariables">
<cfset var correctStruct = structNew()>
<cfset var correct_Struct2 = structNew()>
<!--- This is for unit test, update if test case changes --->
<cfreturn 4>
<cfset correctStruct.foo = "">
<cfset correctStruct.foo2 = "">
<cfset correctStruct[foo3] = "">
<cfset correct_Struct2.foo = "">
<cfset unscopedStruct.foo = "" />
<cfset unscopedStruct2[foo] = "" />
<cfset unscoped_2.unscopedStruct = "" />
<!--- This is a new example, should be showing up --->
<cfset unscopedStruct25["someKey"] = correctStruct />
</cffunction>
<cffunction name="invokeTest">
<cfset var correctInvoke = "">
<cfset var correctStruct = structNew() />
<cfset var correctArray = structNew() />
<!--- This is for unit test, update if test case changes --->
<cfreturn 3>
<cfinvoke returnvariable="correctInvoke" method="foo">
<cfinvoke returnvariable="unscopedInvoke" method="foo">
<cfinvoke returnvariable="correctStruct.Invoke" method="foo">
<cfinvoke returnvariable="unscopedstruct.Invoke" method="foo">
<cfinvoke returnvariable="correctArray[Invoke]" method="foo">
<cfinvoke returnvariable="unscopedarray[Invoke]" method="foo">
</cffunction>
<cffunction name="problem_b">
<!--- This is for unit test, update if test case changes --->
<cfreturn 1>
<cfprocparam variable="unscopedProcParamOut" type="out" cfsqltype="CF_SQL_BIGINT" />
<cfprocparam variable="correctProcParamIn" type="in" cfsqltype="CF_SQL_BIGINT" />
</cffunction>
<cffunction name="problem_a">
<cfset var properScope = structNEw()>
<cfreturn 3>
<cfset properScope.foo2['#foo2#'] = ""/>
<cfset "test.go#i#" = 1 />
<cfset foo2.unscoped.foo[i] = "" />
<cfset foo5.unscoped.foo["i"] = "" />
</cffunction>
<cffunction name="cfparam">
<cfreturn 1>
<!--- These were resolved in 1.00 --->
<cfparam name="foo.results.foo[i]" default="" />
<!--- Returns false positives --->
<cfparam name="variables.foo2[""#foo2#""]" default="">
<cfparam name="variables.foo3.#arguments.message#" default="">
</cffunction>
<!--- This returns false positives --->
<cffunction name="invokeListener" access="public">
<cfargument name="event" type="cfcunit.machii.framework.Event" required="false" />
<cfargument name="listener" required="false" />
<cfargument name="method" type="string" required="false" />
<cfargument name="resultKey" type="string" required="false" default="" />
<cfreturn 0>
<cftry>
<cfinvoke
component="#arguments.listener#"
method="#arguments.method#"
event="#arguments.event#"
returnvariable="#arguments.resultKey#" />
<cfcatch type="Any">
<cfrethrow />
</cfcatch>
</cftry>
</cffunction>
<cffunction name="cfscript_vars_a" access="public" >
<cfscript>
var correctSimpleVar ="bar";
VAR correctSimpleVar2 = "";
vAr correctSimpleVar3 ="bar";
var correctSimpleVar4 = "";
var correctSimpleVar5 = ""; //comments after var
</cfscript>
<cfreturn 4>
<cfscript>
correctSimpleVar ="bar";
correctSimpleVar2 = "";
correctSimpleVar3 ="bar";
correctSimpleVar4 = '';
correctSimpleVar4
=
""
;
correctSimpleVar5 = "b l a" ; //comments
unscopedSimpleVar ="bar";
unscopedSimpleVar2 = "";
unscopedSimpleVar3 ="bar";
unscopedSimpleVar4
=
""
;
</cfscript>
</cffunction>
<cffunction name="cfscript_loops_structs" access="public" >
<cfscript>
var correctStruct = structNew();
var correctLoop = "";
var stFile = "";
var sFileName = "";
var rowData = "";
var foo4 = "";
</cfscript>
<cfreturn 2>
<cfscript>
correctStruct.test = ""
;
for(correctLoop=1;correctLoop LTE 10; correctLoop=correctLoop+1) correctSimpleVar = correctLoop;
for ( correctLoop=1;correctLoop LTE 10; correctLoop=correctLoop+1) correctSimpleVar = correctLoop;for(correctLoop=1;correctLoop LTE 10; correctLoop=correctLoop+1) correctSimpleVar = correctLoop;
for (unscopedLoop=1;unscopedLoop LTE 10; unscopedLoop=unscopedLoop+1) unscopedSimpleVar = unscopedLoop;
for (correctLoop = someFunction();correctLoop LTE 10; correctLoop = correctLoop+1) ;
unscopedStruct.test = ""
;
</cfscript>
</cffunction>
<cffunction name="cfscript_problems" access="public" >
<cfscript>
var stFile_ok = '';
var sFileName_ok = '';
var rowdata2_ok = '';
</cfscript>
<cfreturn 4>
<cfscript>
stFile = variables.related_ID;
stFile_ok["#variables.sRelatedField#"] = variables.related_ID;
// replace special characters
sFileName = variables.oFileSystem.checkFileName(stUploadedFile.ClientFile);
sFileName_ok = variables.oFileSystem.checkFileName(stUploadedFile.ClientFile);
rowdata2[fieldElement.XmlAttributes["name"]] = fieldElement.XmlAttributes["value"];
rowdata2_ok[fieldElement.XmlAttributes["name"]] = fieldElement.XmlAttributes["value"];
"dynamic.st#I18n#" = structNew();
variables.logger.writelog('Access Denied for
#sFacade.getUserBean().getEmailAddress()# @ #cgi.remote_addr# to event=#arguments.event.getValue("requestedEvent")#', "ERROR");
</cfscript>
<cfscript>variables.Logger.logDebug("looking in NDS server #ndsServer# as #ndsUser# for cn=#arguments.username#");</cfscript>
</cffunction>
<cffunction name="cfscript_complex">
<cfscript>
var arr = "";
var startRow = "";
var newStruct = structNew();
</cfscript>
<cfreturn 5>
<cfscript>
arr[1] = foo;
if (1 EQ 1)
startRow = 1;
else
startRow = 2;
if (len(sFileext))
sNewFilename = sNewFilename & "." & sFileext;
if ( Find( '.', prefix ) eq 1 )
prefix = RemoveChars( prefix, 1, 1 );
if (structKeyExists(newStruct, prefix) AND structKeyExists(newStruct, prefix))
"request.st#listLast(sBundle, "\/")#" = prefix;
else
"request.st#listLast(sBundle, "\/")#" = prefix;
CheckMimeType(mimetype_ID=qFile.mimetype_ID);
unscoped3.unscoped.foo["i"] = "";
unscoped10.unscoped.foo['i'] = "";
unscoped4.unscoped.foo["#i#"] = "";
</cfscript>
</cffunction>
<cffunction name="cfscript_vars_2">
<cfscript>
var currentMode=''; // loop index
var currentKeyword=''; // loop index
var tmpQuery=''; // temp query holder
var ReturnStruct=structnew();
var stUploadedFile='';
return 0;
ReturnStruct.Query='';
ReturnStruct.TotRows='';
currentMode = '';
stUploadedFile = variables.oFileSystem.uploadFile(arguments.sFormField,variables.sTempPath,"*/* ");
</cfscript>
</cffunction>
</cfcomponent>