@@ -207,15 +207,14 @@ module ActionDispatch {
207
207
override Location getLocation ( ) { result = call .getLocation ( ) }
208
208
209
209
override string getPathComponent ( ) {
210
- result = call .getKeywordArgument ( "path" ) .getConstantValue ( ) .getStringOrSymbol ( )
210
+ call .getKeywordArgument ( "path" ) .getConstantValue ( ) .isStringOrSymbol ( result )
211
211
or
212
212
not exists ( call .getKeywordArgument ( "path" ) ) and
213
- result = call .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
213
+ call .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
214
214
}
215
215
216
216
override string getControllerComponent ( ) {
217
- result = call .getKeywordArgument ( "controller" ) .getConstantValue ( ) .getStringOrSymbol ( ) or
218
- result = call .getKeywordArgument ( "module" ) .getConstantValue ( ) .getStringOrSymbol ( )
217
+ call .getKeywordArgument ( [ "controller" , "module" ] ) .getConstantValue ( ) .isStringOrSymbol ( result )
219
218
}
220
219
}
221
220
@@ -244,9 +243,7 @@ module ActionDispatch {
244
243
MethodCall getDefiningMethodCall ( ) { result = call }
245
244
246
245
override string getPathComponent ( ) {
247
- exists ( string resource |
248
- resource = call .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
249
- |
246
+ exists ( string resource | call .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( resource ) |
250
247
result = resource + "/:" + singularize ( resource ) + "_id"
251
248
)
252
249
}
@@ -309,7 +306,7 @@ module ActionDispatch {
309
306
override string getControllerComponent ( ) { result = this .getNamespace ( ) }
310
307
311
308
private string getNamespace ( ) {
312
- result = call .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
309
+ call .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
313
310
}
314
311
315
312
override string toString ( ) { result = call .toString ( ) }
@@ -508,11 +505,11 @@ module ActionDispatch {
508
505
override RouteBlock getParentBlock ( ) { result = parentBlock }
509
506
510
507
override string getLastPathComponent ( ) {
511
- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
508
+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
512
509
}
513
510
514
511
override string getLastControllerComponent ( ) {
515
- result = method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .getStringOrSymbol ( )
512
+ method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .isStringOrSymbol ( result )
516
513
or
517
514
not exists ( method .getKeywordArgument ( "controller" ) ) and
518
515
(
@@ -536,15 +533,15 @@ module ActionDispatch {
536
533
}
537
534
538
535
private string getActionString ( ) {
539
- result = method .getKeywordArgument ( "to" ) .getConstantValue ( ) .getStringOrSymbol ( )
536
+ method .getKeywordArgument ( "to" ) .getConstantValue ( ) .isStringOrSymbol ( result )
540
537
or
541
538
method .getKeywordArgument ( "to" ) .( MethodCall ) .getMethodName ( ) = "redirect" and
542
539
result = "<redirect>#<redirect>"
543
540
}
544
541
545
542
override string getAction ( ) {
546
543
// get "/photos", action: "index"
547
- result = method .getKeywordArgument ( "action" ) .getConstantValue ( ) .getStringOrSymbol ( )
544
+ method .getKeywordArgument ( "action" ) .getConstantValue ( ) .isStringOrSymbol ( result )
548
545
or
549
546
not exists ( method .getKeywordArgument ( "action" ) ) and
550
547
(
@@ -559,7 +556,7 @@ module ActionDispatch {
559
556
or
560
557
// get :some_action
561
558
not exists ( this .getActionString ( ) ) and
562
- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
559
+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
563
560
)
564
561
}
565
562
@@ -606,7 +603,7 @@ module ActionDispatch {
606
603
607
604
ResourcesRoute ( ) {
608
605
this = TResourcesRoute ( parent , method , action ) and
609
- resource = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( ) and
606
+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( resource ) and
610
607
isDefaultResourceRoute ( resource , httpMethod , pathComponent , action )
611
608
}
612
609
@@ -617,7 +614,7 @@ module ActionDispatch {
617
614
override string getLastPathComponent ( ) { result = pathComponent }
618
615
619
616
override string getLastControllerComponent ( ) {
620
- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
617
+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
621
618
}
622
619
623
620
override string getAction ( ) { result = action }
@@ -643,7 +640,7 @@ module ActionDispatch {
643
640
644
641
SingularResourceRoute ( ) {
645
642
this = TResourceRoute ( parent , method , action ) and
646
- resource = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( ) and
643
+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( resource ) and
647
644
isDefaultSingularResourceRoute ( resource , httpMethod , pathComponent , action )
648
645
}
649
646
@@ -654,7 +651,7 @@ module ActionDispatch {
654
651
override string getLastPathComponent ( ) { result = pathComponent }
655
652
656
653
override string getLastControllerComponent ( ) {
657
- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
654
+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
658
655
}
659
656
660
657
override string getAction ( ) { result = action }
@@ -685,14 +682,15 @@ module ActionDispatch {
685
682
override RouteBlock getParentBlock ( ) { result = parent }
686
683
687
684
override string getLastPathComponent ( ) {
688
- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( ) or
689
- result = method .getArgument ( 0 ) .( Pair ) .getKey ( ) .getConstantValue ( ) .getStringOrSymbol ( )
685
+ [ method .getArgument ( 0 ) , method .getArgument ( 0 ) .( Pair ) .getKey ( ) ]
686
+ .getConstantValue ( )
687
+ .isStringOrSymbol ( result )
690
688
}
691
689
692
690
override string getLastControllerComponent ( ) {
693
691
result =
694
692
extractController ( method .getKeywordArgument ( "to" ) .getConstantValue ( ) .getStringOrSymbol ( ) ) or
695
- result = method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .getStringOrSymbol ( ) or
693
+ method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .isStringOrSymbol ( result ) or
696
694
result =
697
695
extractController ( method
698
696
.getArgument ( 0 )
@@ -704,7 +702,7 @@ module ActionDispatch {
704
702
705
703
override string getHTTPMethod ( ) {
706
704
exists ( string via |
707
- via = method .getKeywordArgument ( "via" ) .getConstantValue ( ) .getStringOrSymbol ( )
705
+ method .getKeywordArgument ( "via" ) .getConstantValue ( ) .isStringOrSymbol ( via )
708
706
|
709
707
via = "all" and result = anyHttpMethod ( )
710
708
or
@@ -722,7 +720,7 @@ module ActionDispatch {
722
720
723
721
override string getAction ( ) {
724
722
result = extractAction ( method .getKeywordArgument ( "to" ) .getConstantValue ( ) .getStringOrSymbol ( ) ) or
725
- result = method .getKeywordArgument ( "action" ) .getConstantValue ( ) .getStringOrSymbol ( ) or
723
+ method .getKeywordArgument ( "action" ) .getConstantValue ( ) .isStringOrSymbol ( result ) or
726
724
result =
727
725
extractAction ( method .getArgument ( 0 ) .( Pair ) .getValue ( ) .getConstantValue ( ) .getStringOrSymbol ( ) )
728
726
}
@@ -740,19 +738,16 @@ module ActionDispatch {
740
738
not exists ( m .getKeywordArgument ( "only" ) )
741
739
or
742
740
exists ( Expr only | only = m .getKeywordArgument ( "only" ) |
743
- [ only .( ArrayLiteral ) .getElement ( _) , only .( StringlikeLiteral ) ]
744
- .getConstantValue ( )
745
- .getStringOrSymbol ( ) = action
741
+ [ only .( ArrayLiteral ) .getElement ( _) , only ] .getConstantValue ( ) .isStringOrSymbol ( action )
746
742
)
747
743
) and
748
744
// Respect the `except` keyword argument, which removes actions from the default set.
749
745
(
750
746
not exists ( m .getKeywordArgument ( "except" ) )
751
747
or
752
748
exists ( Expr except | except = m .getKeywordArgument ( "except" ) |
753
- [ except .( ArrayLiteral ) .getElement ( _) , except .( StringlikeLiteral ) ]
754
- .getConstantValue ( )
755
- .getStringOrSymbol ( ) != action
749
+ [ except .( ArrayLiteral ) .getElement ( _) , except ] .getConstantValue ( ) .getStringOrSymbol ( ) !=
750
+ action
756
751
)
757
752
)
758
753
}
0 commit comments