Skip to content

Add check for forbidden functions#1259

Open
s3cur3 wants to merge 3 commits intorrrene:masterfrom
s3cur3:ty/forbidden-function
Open

Add check for forbidden functions#1259
s3cur3 wants to merge 3 commits intorrrene:masterfrom
s3cur3:ty/forbidden-function

Conversation

@s3cur3
Copy link
Copy Markdown
Contributor

@s3cur3 s3cur3 commented Feb 7, 2026

This complements the existing Credo.Check.Warning.ForbiddenModule. In our codebase, there are a number of specific functions from otherwise mundane modules that we'd like to forbid. For instance, :erlang.binary_to_term/{1,2} is one we found being used in a surprisingly (scarily) large number of places.

This functionality could potentially be included as an expansion of ForbiddenModule, but it would actually make more sense to me to go the other way and allow ForbiddenFunction to be configured to warn on all functions in a given module. Not sure if that's worth the churn, though.

This complements the existing `Credo.Check.Warning.ForbiddenModule`. In our codebase, there are a number of specific functions from otherwise mundane modules that we'd like to forbid. For instance, `:erlang.binary_to_term/{1,2}` is one we found being used in a surprisingly (scarily) large number of places.

This functionality could potentially be included as an expansion of `ForbiddenModule`, but it would actually make more sense to me to go the other way and allow ForbiddenFunction to be configured to warn on all functions in a given module.
@@ -0,0 +1,96 @@
defmodule Credo.Check.Warning.ForbiddenFunction do

Check warning

Code scanning / Credo

Modules should have a @moduledoc tag. Warning

Modules should have a @moduledoc tag.
@rrrene
Copy link
Copy Markdown
Owner

rrrene commented Feb 10, 2026

I like this, just need a bit of time to merge/integrate it 👍

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.

3 participants