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

Refactor ForbidUntypedStructProps #148

Merged
merged 1 commit into from
Feb 21, 2023

Conversation

sambostock
Copy link
Contributor

This makes the following changes:

  • Consolidates T::Struct and T::ImmutableStruct node matchers.
  • Use a capture in node search instead of indexing into child nodes.

@sambostock sambostock requested a review from paracycle February 21, 2023 15:19
@sambostock sambostock requested a review from a team as a code owner February 21, 2023 15:19
PATTERN

def on_class(node)
return unless subclass_of_t_struct?(node)

untyped_props(node).each do |untyped_prop|
add_offense(untyped_prop.child_nodes[1])
untyped_props(node).each do |prop_type|
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind adding a comment here or on top of def_node_search :untyped_props that says that the ${ ... } part in the node matcher is what captures the prop_type here.

I like the terseness of the usage, but it might be hard to understand what's going on for someone new to the project.

This makes the following changes:

- Consolidates `T::Struct` and `T::ImmutableStruct` node matchers.
- Use a capture in node search instead of indexing into child nodes.
@sambostock sambostock force-pushed the refactor-forbid-untyped-struct-props branch from ce26473 to 758bf9e Compare February 21, 2023 21:20
@sambostock sambostock merged commit f234d4e into main Feb 21, 2023
@sambostock sambostock deleted the refactor-forbid-untyped-struct-props branch February 21, 2023 21:24
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.

2 participants