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

Skip child nodes if parent node is tagged as a shim #187

Merged
merged 3 commits into from
Nov 24, 2023
Merged

Conversation

KaanOzkan
Copy link
Contributor

Needed for #180 where we can't load the constants.

Currently tagging the class with @shim doesn't affect child nodes and the method definitions fail the runtime check. This change resolves that use case by skipping the method definitions as well.

@KaanOzkan KaanOzkan requested a review from a team as a code owner November 23, 2023 20:46
@@ -20,16 +20,19 @@ def initialize(context)
def visit(node)
return unless node

validate_node!(node)
visit_all(node.nodes) if node.is_a?(RBI::Tree)
skip = validate_node!(node)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not convinced by the approach here, if we add more annotations it will quickly get messy .

I think we need to separate the 3 concepts here:

  1. First, let's move the validate_annotations! in the visit rather than having it nested in the validate_node!
  2. Add is_shim? method so we can cleanly say if we want to validate the definition or not
  3. Maybe rename the validate_node! as validate_definition! and not make it validate the annotations

@KaanOzkan KaanOzkan force-pushed the ko/shim-classes branch 2 times, most recently from ae039e3 to b8cec39 Compare November 24, 2023 17:47

# Do not test definitions tagged `@shim`
return if annotations.include?("shim")
def is_shim?(annotations)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def is_shim?(annotations)
def shim?(annotations)

@KaanOzkan KaanOzkan merged commit 03c6e04 into main Nov 24, 2023
3 checks passed
@KaanOzkan KaanOzkan deleted the ko/shim-classes branch November 24, 2023 21:19
@KaanOzkan KaanOzkan mentioned this pull request Nov 24, 2023
2 tasks
@Morriar Morriar added the chore label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants