Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Exception modules should be named consistently #1174

Open
joshk opened this issue Jan 7, 2025 · 1 comment
Open

Incorrect Exception modules should be named consistently #1174

joshk opened this issue Jan 7, 2025 · 1 comment

Comments

@joshk
Copy link

joshk commented Jan 7, 2025

Environment

  • Credo version (mix credo -v): 1.7.11
  • Erlang/Elixir version (elixir -v): 1.18.0
  • Operating system: Mac 15.1.1

What were you trying to do?

defmodule NervesHub.Errors.Unauthorized do
  defexception message: "not found", plug_status: 404
end

defmodule NervesHubWeb.NotFoundError do
  defexception message: "not found", plug_status: 404
end

defmodule NervesHubWeb.UnauthorizedError do
  defexception message: "forbidden", plug_status: 401
end

Expected outcome

No warnings.

Actual outcome

  Consistency
┃
┃ [C] ↗ Exception modules should be named consistently. It seems your strategy is to prefix them with `Unauthorized`, but
┃       `NervesHubWeb.NotFoundError` does not follow that convention.
┃       lib/nerves_hub_web/errors.ex:5:11 #(NervesHubWeb.NotFoundError)
@joshk
Copy link
Author

joshk commented Jan 8, 2025

Although I do regard this as a bug, I did fix this by reworking our code a little to remove the duplicate Unauthorized exception.

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

No branches or pull requests

1 participant