D4no0
I have a project currently that I want to ban calls to some functions. Currently, all of those functions are either from a library or standard elixir library.
Since I have already a credo pipeline running, I was wondering if it would be possible to define a custom rule for this, or maybe there is already an existing rule for this (I could not find it).
Has anyone managed to do this successfully?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
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
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
krasenyp
I haven’t seen such rule and don’t know how to implement it but I’m curious about your use case as I too want to do something similar. In my case it’s related to capability-based development.
sodapopcan
I made one to ban
assign/2.thenis nextIt also checks for a single pipe into
assign. I can’t remember why I did this instead of using the existing credo rule but I assume it’s because sometimes I’m ok with single pipes. This was a while ago.D4no0
Nice! This is exactly what I was looking for.
Do you think it’s possible to define all the banned functions in a single check or there are advantages to having them separated?
sodapopcan
I’d say it’s definitely fine to do all of them in a single check. Certainly less code. I think the only advantage in using multiple checks is giving more details about why specific functions are banned per error as opposed to just a big “don’t
aorborcord” but if you aren’t distributing it then one big one is fine.Rereading this a perhaps slightly clearer way to write the check would be:
EDIT: I royally hecked up my refactor there—it made no sense as I was using
Fixed it, but now it’s only maybe marginally better.
elemon a list and&&in a guardEDIT 2: I should really stop answering questions first thing in the morning. I re-edited it, not that is really matters
I also realized the way I had it there it’s possible to get around the rule by not calling the socket variable
socket, so perhaps you don’t even want to check for that. Ok, I’m really done now (probably, lol).sodapopcan
Last update: I release I was wrong, based on the first arg to
issue_foryou can determine which function was called and tailor the error there. So really it just seems to be about the moduledoc as well as being able to easily turn certain ones on and off, but in your situation I would say there are no disadvantages.thiagomajesk
Do you need to have a Credo rule for this or is the goal just to block calls to those functions? If you don’t need to necessarily use Credo, take a look at the Boundary library.
D4no0
I am already using Boundary, but that is only good to organize the application code. I need specifically to block functionality either from standard or external libraries.
thiagomajesk
Doesn’t it actually raise warnings at compilation time? I imagine that could be paired with
mix compile --warning-as-errors, no!? From the roadmap, it seems it also supports validating calls to external deps.D4no0
I think theoretically you could do that, however I think that using Boundary in this case is not a good fit, especially since I have multiple top boundaries in my application.
I personally use Boundary to organize business logic in well-structured module hierarchies. Banning function calls falls in the lint region of the project, where this is more of a enforceable guideline to follow for existing and new code.
thiagomajesk
I mean, that’s a core feature of the library, but since it’s a matter of preference, I’m glad you found something that works for you with Credo. Good luck with it
