Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dead code plugins to reason on the classes hierarchy #568

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

Morriar
Copy link
Collaborator

@Morriar Morriar commented Jun 20, 2024

Closes: #505.

This PR exposes the Model POSet to the plugins so they can use complete class hierarchy information to determine if the analyzed class is a descendant of another class.

Consider this example:

class ApplicationController; end
class MyAbstractController < ApplicationController; end
class MyController < MyAbstractController; end

Before this change, a plugin working on MyController didn't have any global knowledge about the codebase and couldn't see farther than the direct superclass of MyAbstractController, this led use to use some Regex hacking on the class name like filtering classes names based on /Controller$/.

With Model#symbols_hierarchy we can finally get the full ancestry and see that MyController indeed descends from ApplicationController.

Morriar added 3 commits June 20, 2024 10:28
So we can access the symbols hierarchy

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar added the feature New feature label Jun 20, 2024
@Morriar Morriar self-assigned this Jun 20, 2024
@Morriar Morriar requested a review from a team as a code owner June 20, 2024 14:34
@Morriar Morriar requested review from egiurleo and KaanOzkan June 20, 2024 14:34
Copy link
Contributor

@egiurleo egiurleo left a comment

Choose a reason for hiding this comment

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

Nice!

Base automatically changed from at-model-deadcode to main June 20, 2024 17:21
@Morriar Morriar merged commit b4ad777 into main Jun 20, 2024
8 checks passed
@Morriar Morriar deleted the at-deadcode-poset branch June 20, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose proper way to handle inheritance to plugins
2 participants