@@ -207,15 +207,14 @@ module ActionDispatch {
207207 override Location getLocation ( ) { result = call .getLocation ( ) }
208208
209209 override string getPathComponent ( ) {
210- result = call .getKeywordArgument ( "path" ) .getConstantValue ( ) .getStringOrSymbol ( )
210+ call .getKeywordArgument ( "path" ) .getConstantValue ( ) .isStringOrSymbol ( result )
211211 or
212212 not exists ( call .getKeywordArgument ( "path" ) ) and
213- result = call .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
213+ call .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
214214 }
215215
216216 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 )
219218 }
220219 }
221220
@@ -244,9 +243,7 @@ module ActionDispatch {
244243 MethodCall getDefiningMethodCall ( ) { result = call }
245244
246245 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 ) |
250247 result = resource + "/:" + singularize ( resource ) + "_id"
251248 )
252249 }
@@ -309,7 +306,7 @@ module ActionDispatch {
309306 override string getControllerComponent ( ) { result = this .getNamespace ( ) }
310307
311308 private string getNamespace ( ) {
312- result = call .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
309+ call .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
313310 }
314311
315312 override string toString ( ) { result = call .toString ( ) }
@@ -508,11 +505,11 @@ module ActionDispatch {
508505 override RouteBlock getParentBlock ( ) { result = parentBlock }
509506
510507 override string getLastPathComponent ( ) {
511- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
508+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
512509 }
513510
514511 override string getLastControllerComponent ( ) {
515- result = method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .getStringOrSymbol ( )
512+ method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .isStringOrSymbol ( result )
516513 or
517514 not exists ( method .getKeywordArgument ( "controller" ) ) and
518515 (
@@ -536,15 +533,15 @@ module ActionDispatch {
536533 }
537534
538535 private string getActionString ( ) {
539- result = method .getKeywordArgument ( "to" ) .getConstantValue ( ) .getStringOrSymbol ( )
536+ method .getKeywordArgument ( "to" ) .getConstantValue ( ) .isStringOrSymbol ( result )
540537 or
541538 method .getKeywordArgument ( "to" ) .( MethodCall ) .getMethodName ( ) = "redirect" and
542539 result = "<redirect>#<redirect>"
543540 }
544541
545542 override string getAction ( ) {
546543 // get "/photos", action: "index"
547- result = method .getKeywordArgument ( "action" ) .getConstantValue ( ) .getStringOrSymbol ( )
544+ method .getKeywordArgument ( "action" ) .getConstantValue ( ) .isStringOrSymbol ( result )
548545 or
549546 not exists ( method .getKeywordArgument ( "action" ) ) and
550547 (
@@ -559,7 +556,7 @@ module ActionDispatch {
559556 or
560557 // get :some_action
561558 not exists ( this .getActionString ( ) ) and
562- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
559+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
563560 )
564561 }
565562
@@ -606,7 +603,7 @@ module ActionDispatch {
606603
607604 ResourcesRoute ( ) {
608605 this = TResourcesRoute ( parent , method , action ) and
609- resource = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( ) and
606+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( resource ) and
610607 isDefaultResourceRoute ( resource , httpMethod , pathComponent , action )
611608 }
612609
@@ -617,7 +614,7 @@ module ActionDispatch {
617614 override string getLastPathComponent ( ) { result = pathComponent }
618615
619616 override string getLastControllerComponent ( ) {
620- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
617+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
621618 }
622619
623620 override string getAction ( ) { result = action }
@@ -643,7 +640,7 @@ module ActionDispatch {
643640
644641 SingularResourceRoute ( ) {
645642 this = TResourceRoute ( parent , method , action ) and
646- resource = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( ) and
643+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( resource ) and
647644 isDefaultSingularResourceRoute ( resource , httpMethod , pathComponent , action )
648645 }
649646
@@ -654,7 +651,7 @@ module ActionDispatch {
654651 override string getLastPathComponent ( ) { result = pathComponent }
655652
656653 override string getLastControllerComponent ( ) {
657- result = method .getArgument ( 0 ) .getConstantValue ( ) .getStringOrSymbol ( )
654+ method .getArgument ( 0 ) .getConstantValue ( ) .isStringOrSymbol ( result )
658655 }
659656
660657 override string getAction ( ) { result = action }
@@ -685,14 +682,15 @@ module ActionDispatch {
685682 override RouteBlock getParentBlock ( ) { result = parent }
686683
687684 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 )
690688 }
691689
692690 override string getLastControllerComponent ( ) {
693691 result =
694692 extractController ( method .getKeywordArgument ( "to" ) .getConstantValue ( ) .getStringOrSymbol ( ) ) or
695- result = method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .getStringOrSymbol ( ) or
693+ method .getKeywordArgument ( "controller" ) .getConstantValue ( ) .isStringOrSymbol ( result ) or
696694 result =
697695 extractController ( method
698696 .getArgument ( 0 )
@@ -704,7 +702,7 @@ module ActionDispatch {
704702
705703 override string getHTTPMethod ( ) {
706704 exists ( string via |
707- via = method .getKeywordArgument ( "via" ) .getConstantValue ( ) .getStringOrSymbol ( )
705+ method .getKeywordArgument ( "via" ) .getConstantValue ( ) .isStringOrSymbol ( via )
708706 |
709707 via = "all" and result = anyHttpMethod ( )
710708 or
@@ -722,7 +720,7 @@ module ActionDispatch {
722720
723721 override string getAction ( ) {
724722 result = extractAction ( method .getKeywordArgument ( "to" ) .getConstantValue ( ) .getStringOrSymbol ( ) ) or
725- result = method .getKeywordArgument ( "action" ) .getConstantValue ( ) .getStringOrSymbol ( ) or
723+ method .getKeywordArgument ( "action" ) .getConstantValue ( ) .isStringOrSymbol ( result ) or
726724 result =
727725 extractAction ( method .getArgument ( 0 ) .( Pair ) .getValue ( ) .getConstantValue ( ) .getStringOrSymbol ( ) )
728726 }
@@ -740,19 +738,16 @@ module ActionDispatch {
740738 not exists ( m .getKeywordArgument ( "only" ) )
741739 or
742740 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 )
746742 )
747743 ) and
748744 // Respect the `except` keyword argument, which removes actions from the default set.
749745 (
750746 not exists ( m .getKeywordArgument ( "except" ) )
751747 or
752748 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
756751 )
757752 )
758753 }
0 commit comments