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 DuplicatedCode not matching blocks with external calls #652

Merged
merged 1 commit into from May 3, 2019

Conversation

Projects
None yet
2 participants
@liskin
Copy link
Contributor

commented Apr 29, 2019

DuplicatedCode (and other checks which use Credo.Code.remove_metadata)
would fail to detect duplicities whenever there are any external
function calls (aliases in AST) and the duplicities don't happen to be
at exactly the same line numbers. So credo would detect if two modules
are exactly equal, but adding a "# creeedo:disabled-four-that-foul"
comment on top is enough to disable the check, which doesn't seem very
intentional. :-)

This is because Credo.Code.update_metadata doesn't recurse into

{{:., …, …}, …, …}

nodes. Fix this by dropping the hand-crafted implementation and use
Macro.prewalk and Macro.update_meta instead.

Fix DuplicatedCode not matching blocks with external calls
DuplicatedCode (and other checks which use Credo.Code.remove_metadata)
would fail to detect duplicities whenever there are any external
function calls (aliases in AST) and the duplicities don't happen to be
at exactly the same line numbers. So credo would detect if two modules
are exactly equal, but adding a "# creeedo:disabled-four-that-foul"
comment on top is enough to disable the check, which doesn't seem very
intentional. :-)

This is because Credo.Code.update_metadata doesn't recurse into

    {{:., …, …}, …, …}

nodes. Fix this by dropping the hand-crafted implementation and use
Macro.prewalk and Macro.update_meta instead.

@rrrene rrrene merged commit bb4da31 into rrrene:master May 3, 2019

@rrrene

This comment has been minimized.

Copy link
Owner

commented May 3, 2019

@liskin Thx! 👍

@liskin liskin deleted the liskin:fix-aliases-in-duplicated-code branch May 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.