sasa1977 / boundary

Manage and restrain cross-module dependencies in Elixir projects
MIT License
818 stars 21 forks source link

Is boundary able to check cross-boundary calls via render function. #30

Closed Skoda091 closed 3 years ago

Skoda091 commented 3 years ago

Situation

Concerning that, I have defined two boundaries

defmodule MySystem.Account do
 use Boundary, top_level?: true, deps: [], exports: []
end
defmodule MySystem.Blog do
 use Boundary, top_level?: true, deps: [], exports: []
end

I do a cross-boundary call via render_many/4

defmodule MySystem.Account.UserView do
 ...
 def render("index.json", users) do
    %{users: render_many(users,  MySystem.Blog.UserView, "user.json"}
  end
 ...
end

Is boundary able to generate forbidden call to MySystem.Blog.UserView warnings in such a case?

sasa1977 commented 3 years ago

Currently no. Boundary will only warn about explicit function call (Foo.bar()). Referencing a module without calling it (e.g. apply(Foo, :bar, []) isn't reported.

I think that this is technically possible, but it needs to be tried out.

Skoda091 commented 3 years ago

That would be great if this would be possible. I will try it out in my spare time.

sasa1977 commented 3 years ago

I've just published version 0.8.0 where this is possible. However, it's not turned on by default. See here for details.