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

Exclude Mint.HTTP module from warnings #51

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aleDsz
Copy link
Member

@aleDsz aleDsz commented Nov 7, 2022

==> kino_db
Compiling 4 files (.ex)
warning: Mint.HTTP.connect/3 is undefined (module Mint.HTTP is not available or is yet to be defined)
  lib/kino_db/connection_cell.ex:395: KinoDB.ConnectionCell.running_on_google_metadata?/0

warning: Mint.HTTP.set_mode/2 is undefined (module Mint.HTTP is not available or is yet to be defined)
  lib/kino_db/connection_cell.ex:396: KinoDB.ConnectionCell.running_on_google_metadata?/0

Generated kino_db app

@josevalim
Copy link
Contributor

Wait, do we use @compile {:no_warn_undefined, ...} anywhere else in this project. If so, perhaps we should do the same in KinoDB.ConnectionCell. Otherwise this patch is good to go!

@wojtekmach
Copy link

Yeah, we have one occurrence:

lib/kino_db/sql_cell.ex
113:  @compile {:no_warn_undefined, {DBConnection, :connection_module, 1}}

+1 on standardising either way. :)

@@ -391,6 +391,8 @@ defmodule KinoDB.ConnectionCell do

defp help_box(_ctx), do: nil

@compile {:no_warn_undefined, {Mint.HTTP, :connect, 3}, {Mint.HTTP, :set_mode, 2}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be two lines like you previously had:

Suggested change
@compile {:no_warn_undefined, {Mint.HTTP, :connect, 3}, {Mint.HTTP, :set_mode, 2}}
@compile {:no_warn_undefined, {Mint.HTTP, :connect, 3}}
@compile {:no_warn_undefined, {Mint.HTTP, :set_mode, 2}}

pro-tip, the way I tested it was:

$ elixir -e 'Mix.install [{:kino_db, path: "~/src/kino_db"}], force: true'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or mix compile --force --no-optional-deps 🐱

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, forgot about that one. we should add it to CI if we don't have it already :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, @aleDsz feel free to add as part of this PR :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With mix compile --warnings-as-errors --force --no-optional-deps it still fails

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this seems like a bug. I noticed with [xref: [exclude: [Mint.HTTP]] it works correctly but with @compile ... I'm getting:

~/src/kino_db[main]% mix compile --warnings-as-errors --no-optional-deps --force
Compiling 4 files (.ex)
warning: Mint.HTTP.connect/3 defined in application :mint is used by the current application but the current application does not depend on :mint. To fix this, you must do one of:

  1. If :mint is part of Erlang/Elixir, you must include it under :extra_applications inside "def application" in your mix.exs

  2. If :mint is a dependency, make sure it is listed under "def deps" in your mix.exs

  3. In case you don't want to add a requirement to :mint, you may optionally skip this warning by adding [xref: [exclude: [Mint.HTTP]]] to your "def project" in mix.exs

  lib/kino_db/connection_cell.ex:398: KinoDB.ConnectionCell.running_on_google_metadata?/0

warning: Mint.HTTP.set_mode/2 defined in application :mint is used by the current application but the current application does not depend on :mint. To fix this, you must do one of:

  1. If :mint is part of Erlang/Elixir, you must include it under :extra_applications inside "def application" in your mix.exs

  2. If :mint is a dependency, make sure it is listed under "def deps" in your mix.exs

  3. In case you don't want to add a requirement to :mint, you may optionally skip this warning by adding [xref: [exclude: [Mint.HTTP]]] to your "def project" in mix.exs

  lib/kino_db/connection_cell.ex:399: KinoDB.ConnectionCell.running_on_google_metadata?/0

Compilation failed due to warnings while using the --warnings-as-errors option

For anyone else testing this locally, first do rm -rf _build. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's odd, because DBConnection doesn't fail

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.

4 participants