-
Notifications
You must be signed in to change notification settings - Fork 414
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
Add nested function calls check #933
Add nested function calls check #933
Conversation
# Elixir >= 1.8.0 | ||
# '__#{val}__' are compiled to String.to_charlist("__#{val}__") | ||
# we want to consider these charlists a valid pipe chain start | ||
defp valid_chain_start?({{:., _, [List, :to_charlist]}, _, [[_ | _]]}), do: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if these two charlist clauses are needed or not. I copied them from Credo.Check.Refactor.PipeChainStart
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment does irritate me a bit as it sounds like you made copy-pasta and are asking me if you did it correctly? Maybe I'm misunderstanding the question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did copy-and-paste this code from the Credo.Check.Refactor.PipeChainStart
module. I have removed the unnecessary clauses from the function and added some additional tests to validate the remaining code is sufficient.
|
It is a pipeline that does not matter for new checks 👍 |
I'm not sure why the Github workflows haven't run, but I have updated the PR and as far as I know everything is good to merge. |
This PR adds a check named
Credo.Check.Readability.NestedFunctionCalls
that checks for nested function calls that could be converted to pipelines. I created this check to catch violations of the rule about nested function calls specified in the Christopher Adam's style guide (https://github.com/christopheradams/elixir_style_guide#pipe-operator)It tries to be smart enough to handle things like access protocol, string interpolation, and function calls with no arguments. See the tests for examples.
Context: