Extract a Gems::BaseController#479
Open
kaspth wants to merge 6 commits into
Open
Conversation
…methods controllers enable the finder manually
kaspth
commented
Oct 20, 2025
Comment on lines
-60
to
-61
| username: postgres | ||
| password: postgres |
Contributor
Author
There was a problem hiding this comment.
Oops, didn't mean to commit this. I'm confused why we need this username/password though?
Comment on lines
+16
to
+19
| if gem = params[:gem] | ||
| version = perams[:version] || GemSpec.latest_version_for(gem) | ||
| @gem = GemSpec.find(gem, version) or raise GemNotFoundError.new(gem, version) | ||
| end |
Contributor
Author
There was a problem hiding this comment.
I tried to simplify the set_gem finder logic.
Comment on lines
+25
to
+26
| when params[:class_id] then @gem.find_class!(params[:class_id]) | ||
| when params[:module_id] then @gem.find_module!(params[:module_id]) |
Contributor
Author
There was a problem hiding this comment.
It seems like we should have a general @gem.find_const! where the returned object could then have both module?/class? qualifiers on it.
| @gem.info.analyzer | ||
| end | ||
|
|
||
| @namespace = @gem.find_namespace(@target.qualified_namespace) if params[:class_id] |
Contributor
Author
There was a problem hiding this comment.
I wanted to highlight that we were doing extra work in the params[:class_id] case so I pulled it out to it's own line instead of nestling it into the existing conditional branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We've got a subsection of the app that expects and works off of a
@gemvariable. I think it'd be clearer if we made a dedicated hosting place for that than putting it in a concern.Additionally the other controller concerns seem like premature extractions, some only being used in lone controller
showactions. I think it'd be clearer if we inlined them for now.The more complex finder is the
set_targetone that's used in both the gem class/instance methods controllers. It seems like they both share the use ofparams[:class_id]andparams[:module_id]with a fallback to the general analyzer. I don't quite understand the general fallback to the general analyzer, but I kept it for now.