Merge pull request #10598 from hmac/hmac/actioncontroller-metal

Ruby: Identify ActionController::Metal controllers
This commit is contained in:
Harry Maclean
2022-09-30 13:07:03 +13:00
committed by GitHub
4 changed files with 13 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Subclasses of `ActionController::Metal` are now recognised as controllers.

View File

@@ -32,7 +32,12 @@ class ActionControllerControllerClass extends ClassDeclaration {
API::getTopLevelMember("ActionController").getMember("Base"),
// In Rails applications `ApplicationController` typically extends `ActionController::Base`, but we
// treat it separately in case the `ApplicationController` definition is not in the database.
API::getTopLevelMember("ApplicationController")
API::getTopLevelMember("ApplicationController"),
// ActionController::Metal technically doesn't contain all of the
// methods available in Base, such as those for rendering views.
// However we prefer to be over-sensitive in this case in order to find
// more results.
API::getTopLevelMember("ActionController").getMember("Metal")
].getASubclass().getAValueReachableFromSource().asExpr().getExpr()
}

View File

@@ -8,6 +8,7 @@ actionControllerControllerClasses
| app/controllers/foo/bars_controller.rb:3:1:46:3 | BarsController |
| app/controllers/photos_controller.rb:1:1:4:3 | PhotosController |
| app/controllers/posts_controller.rb:1:1:10:3 | PostsController |
| app/controllers/tags_controller.rb:1:1:2:3 | TagsController |
| app/controllers/users/notifications_controller.rb:2:3:5:5 | NotificationsController |
actionControllerActionMethods
| active_record/ActiveRecord.rb:27:3:38:5 | some_request_handler |

View File

@@ -0,0 +1,2 @@
class TagsController < ActionController::Metal
end