Sebb
Credo: how to exclude functions?
The checks PipeChainStart and ABC-Size allow a parameter excluded_functions.
This does not seem to work.
I have this function credo does not like:
def hello do
Kernel.+(1, 1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
|> Kernel.+(1)
end
credo complains:
┃ [F] → Function is too complex (ABC size is 31, max is 30).
┃ lib/credo_check.ex:3:7 #(CredoCheck.hello)
┃ [F] → Pipe chain should start with a raw value.
┃ lib/credo_check.ex:5 #(CredoCheck.hello)
with this config:
{Credo.Check.Refactor.PipeChainStart, [excluded_functions: ["hello"]]},
{Credo.Check.Refactor.ABCSize, [excluded_functions: ["hello"]]},
I also tried
:hello"CredoCheck.hello""hello/0"~r/hello/
Marked As Solved
al2o3cr
Looks like Pipe has similar functionality, for similar reasons:
1
Also Liked
al2o3cr
Based on the tests for PipeChainStart, excluded_functions is a list of functions that are allowed to start a chain, not functions that are allowed to have a chain in them:
You likely want inline config comments on hello instead.
3
gregvaughn
This may be an unwelcome tangent, but credo would not complain if you wrote this code in the more idiomatic way
Worms.Repo.get(Transaction, transaction_id)
1
Popular in Questions
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Other popular topics
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help.
Where are they similar?
Where do they differ the m...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
Hi!
Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








