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

fix(no_successive_maps): prevent failing on nested maps #372

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

bormilan
Copy link
Contributor

@bormilan bormilan commented Nov 10, 2024

Description

I just added the option: traverse => all to the rule because when I investigated the problem with the provided example, I realized that the elvis_code:find does not go deep into this nested map, because the zippers can go deeper only if a node is a branch. A node is identified as a branch if it has something in its content field(if the traverse is set to content). So we need to change traverse to all so the elvis_code can use the node_attrs as the children of the node.

In this example, the rule fails because a map_field_assoc type node contains no content, preventing the function elvis_code:find from going deeper; it only returns that one map.

Closes #339.

Copy link
Collaborator

@paulo-ferraz-oliveira paulo-ferraz-oliveira left a comment

Choose a reason for hiding this comment

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

Looks Ok to me. Thanks.

Copy link
Member

@elbrujohalcon elbrujohalcon left a comment

Choose a reason for hiding this comment

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

I don't understand how you made tests pass on OTP27, but the rest of the PR is cool.

test/examples/fail_no_successive_maps2.erl Show resolved Hide resolved
@elbrujohalcon elbrujohalcon merged commit c19136f into inaka:main Nov 11, 2024
7 checks passed
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.

no_successive_maps doesn't work when nested
3 participants