Last active
March 24, 2022 06:08
-
-
Save trbngr/13c03554eb2d56078c7e42bc6ee7d18d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ShutUpDialyzer do | |
defmacro __using__(_opts) do | |
quote do | |
@on_definition unquote(__MODULE__) | |
@before_compile unquote(__MODULE__) | |
Module.register_attribute(__MODULE__, :funs, accumulate: true) | |
end | |
end | |
def __on_definition__(%{module: module}, :def, name, args, _guards, _body) do | |
fun = Keyword.new([{name, length(args)}]) | |
Module.put_attribute(module, :funs, fun) | |
end | |
defmacro __before_compile__(%{module: module}) do | |
funs = Module.delete_attribute(module, :funs) |> List.flatten() | |
Module.put_attribute(module, :dialyzer, {:nowarn_function, funs}) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SomeModule do | |
use ShutUpDialyzer | |
def do_something do | |
nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment