Skip to content

Extract a Gems::BaseController#479

Open
kaspth wants to merge 6 commits into
marcoroth:mainfrom
kaspth:gems-base-controller
Open

Extract a Gems::BaseController#479
kaspth wants to merge 6 commits into
marcoroth:mainfrom
kaspth:gems-base-controller

Conversation

@kaspth
Copy link
Copy Markdown
Contributor

@kaspth kaspth commented Oct 20, 2025

We've got a subsection of the app that expects and works off of a @gem variable. 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 show actions. I think it'd be clearer if we inlined them for now.

The more complex finder is the set_target one that's used in both the gem class/instance methods controllers. It seems like they both share the use of params[:class_id] and params[: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.

Comment thread config/database.yml
Comment on lines -60 to -61
username: postgres
password: postgres
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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])
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant