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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/kino_db/connection_cell.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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


defp running_on_google_metadata? do
with {:ok, conn} <- Mint.HTTP.connect(:http, "metadata.google.internal", 80),
{:ok, _} <- Mint.HTTP.set_mode(conn, :passive),
Expand Down