Repository: honeybadger-io/honeybadger-elixir (elixir)

Issue:
Logger.warn is deprecated
Compiling on Elixir 1.15.0-rc.1 indicates that some `Logger.warn` calls still need changing or handled gracefully on multiple versions of Elixir. Potential approach   [fyi](https://jeffkreeftmeijer.com/elixir-backwards-compatible-logger/ )
HB version 0.20.0

```
==> honeybadger
Compiling 22 files (.ex)
warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
  lib/honeybadger/client.ex:66: Honeybadger.Client.send_notice/1

warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
  lib/honeybadger/client.ex:140: Honeybadger.Client.handle_cast/2

warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
  lib/honeybadger/client.ex:143: Honeybadger.Client.handle_cast/2

warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
  lib/honeybadger/client.ex:170: Honeybadger.Client.post_notice/4

warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
  lib/honeybadger/client.ex:174: Honeybadger.Client.post_notice/4

warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead
  lib/honeybadger/client.ex:177: Honeybadger.Client.post_notice/4

Generated honeybadger app

Pull request:
Switch to warning/1 with updated build matrix 
This swiitches from `Logger.warn` to `Logger.warning` because `warn` is deprecated, and the upcoming Elixir 1.15 shows a compile-time warning. The `warning` alternative was introduced in Elixir 1.11, so we're officially updating the build matrix to support 1.11 as the minimum Elixir version.

Closes #493

Patch:
diff --git a/.formatter.exs b/.formatter.exs
index 47f13cd..5cf10e2 100644
--- a/.formatter.exs
+++ b/.formatter.exs
@@ -1,12 +1,5 @@
 [
-  inputs: [
-    "*.exs",
-    "config/*.exs",
-    "lib/**/*.ex",
-    "priv/**/*.exs",
-    "scripts/*.exs",
-    "test/**/*.{ex,exs}"
-  ],
+  inputs: ["{mix,.formatter}.exs", "{lib,test}/**/*.{ex,exs}"],
   import_deps: [],
   locals_without_parens: []
 ]
diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml
index abd9952..731c430 100644
--- a/.github/workflows/elixir.yml
+++ b/.github/workflows/elixir.yml
@@ -18,11 +18,11 @@ jobs:
       matrix:
         include:
           - pair:
-              elixir: '1.10'
+              elixir: '1.11'
               otp: '21.3'
           - pair:
-              elixir: '1.12'
-              otp: '24.0'
+              elixir: '1.15'
+              otp: '26.0'
             lint: lint
 
     runs-on: ubuntu-20.04
@@ -43,7 +43,7 @@ jobs:
           restore-keys: ${{ runner.os }}-${{ matrix.pair.otp }}-${{ matrix.pair.elixir }}-mix-
 
       - name: Run mix deps.get
-        run: mix deps.get --only test
+        run: mix deps.ci
 
       - name: Run mix format
         run: mix format --check-formatted
@@ -57,4 +57,4 @@ jobs:
         if: ${{ matrix.lint }}
 
       - name: Run tests
-        run: mix test
+        run: mix test.ci
diff --git a/README.md b/README.md
index 9b24783..c5f0178 100644
--- a/README.md
+++ b/README.md
@@ -14,8 +14,8 @@ Elixir Plug, Logger and client for the :zap: [Honeybadger error notifier](https:
 
 ### Version Requirements
 
-- Erlang >= 18.0
-- Elixir >= 1.10
+- Erlang >= 21.0
+- Elixir >= 1.11
 - Plug >= 1.0
 - Phoenix >= 1.0 (This is an optional dependency and the version requirement applies only if you are using Phoenix)
 
diff --git a/config/config.exs b/config/config.exs
deleted file mode 100644
index 871a3d1..0000000
--- a/config/config.exs
+++ /dev/null
@@ -1,3 +0,0 @@
-import Config
-
-import_config "#{Mix.env()}.exs"
diff --git a/config/dev.exs b/config/dev.exs
deleted file mode 100644
index 41673ca..0000000
--- a/config/dev.exs
+++ /dev/null
@@ -1,3 +0,0 @@
-import Config
-
-config :honeybadger, :environment_name, :dev
diff --git a/dummy/mixapp/config/config.exs b/dummy/mixapp/config/config.exs
deleted file mode 100644
index 707b98b..0000000
--- a/dummy/mixapp/config/config.exs
+++ /dev/null
@@ -1,30 +0,0 @@
-# This file is responsible for configuring your application
-# and its dependencies with the aid of the Mix.Config module.
-import Config
-
-# This configuration is loaded before any dependency and is restricted
-# to this project. If another project depends on this project, this
-# file won't be loaded nor affect the parent project. For this reason,
-# if you want to provide default values for your application for
-# 3rd-party users, it should be done in your "mix.exs" file.
-
-# You can configure your application as:
-#
-#     config :mixapp, key: :value
-#
-# and access this configuration in your application as:
-#
-#     Application.get_env(:mixapp, :key)
-#
-# You can also configure a 3rd-party app:
-#
-#     config :logger, level: :info
-#
-
-# It is also possible to import configuration files, relative to this
-# directory. For example, you can emulate configuration per environment
-# by uncommenting the line below and defining dev.exs, test.exs and such.
-# Configuration from the imported file will override the ones defined
-# here (which is why it is important to import them last).
-#
-#     import_config "#{Mix.env}.exs"
diff --git a/dummy/mixapp/lib/mixapp.ex b/dummy/mixapp/lib/mixapp.ex
deleted file mode 100644
index 2b35b40..0000000
--- a/dummy/mixapp/lib/mixapp.ex
+++ /dev/null
@@ -1,2 +0,0 @@
-defmodule Mixapp do
-end
diff --git a/dummy/mixapp/lib/mixapp/application.ex b/dummy/mixapp/lib/mixapp/application.ex
index a421bef..8bbfb8f 100644
--- a/dummy/mixapp/lib/mixapp/application.ex
+++ b/dummy/mixapp/lib/mixapp/application.ex
@@ -1,20 +1,9 @@
 defmodule Mixapp.Application do
-  # See https://hexdocs.pm/elixir/Application.html
-  # for more information on OTP Applications
   @moduledoc false
 
   use Application
 
   def start(_type, _args) do
-    # List all child processes to be supervised
-    children = [
-      # Starts a worker by calling: Mixapp.Worker.start_link(arg)
-      # {Mixapp.Worker, arg},
-    ]
-
-    # See https://hexdocs.pm/elixir/Supervisor.html
-    # for other strategies and supported options
-    opts = [strategy: :one_for_one, name: Mixapp.Supervisor]
-    Supervisor.start_link(children, opts)
+    Supervisor.start_link([], strategy: :one_for_one, name: Mixapp.Supervisor)
   end
 end
diff --git a/dummy/mixapp/mix.lock b/dummy/mixapp/mix.lock
index 87c2615..8034a09 100644
--- a/dummy/mixapp/mix.lock
+++ b/dummy/mixapp/mix.lock
@@ -1,14 +1,15 @@
 %{
-  "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm", "fdc6066ceeccb3aa14049ab6edf0b9af3b64ae1b0db2a92d5c52146f373bbb1c"},
-  "hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "6b1980a33628824ec829239b6f9bfc455f60eebc19d3096a215f5f6170d675cf"},
-  "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fc1a2f7340c422650504b1662f28fdf381f34cbd30664e8491744e52c9511d40"},
+  "certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"},
+  "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"},
+  "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
   "jason": {:hex, :jason, "1.0.0", "0f7cfa9bdb23fed721ec05419bcee2b2c21a77e926bce0deda029b5adc716fe2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b96c400e04b7b765c0854c05a4966323e90c0d11fee0483b1567cda079abb205"},
   "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
   "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [], [], "hexpm"},
-  "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm", "7a4c8e1115a2732a67d7624e28cf6c9f30c66711a9e92928e745c255887ba465"},
+  "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
+  "parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
   "plug": {:hex, :plug, "1.4.3", "236d77ce7bf3e3a2668dc0d32a9b6f1f9b1f05361019946aae49874904be4aed", [], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
   "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
-  "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm", "4f8805eb5c8a939cf2359367cb651a3180b27dfb48444846be2613d79355d65e"},
+  "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
   "telemetry": {:hex, :telemetry, "0.4.0", "8339bee3fa8b91cb84d14c2935f8ecf399ccd87301ad6da6b71c09553834b2ab", [:rebar3], [], "hexpm", "e9e3cacfd37c1531c0ca70ca7c0c30ce2dbb02998a4f7719de180fe63f8d41e4"},
-  "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm", "da1d9bef8a092cc7e1e51f1298037a5ddfb0f657fe862dfe7ba4c5807b551c29"},
+  "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
 }
diff --git a/lib/honeybadger/client.ex b/lib/honeybadger/client.ex
index 7d410a4..21c72b2 100644
--- a/lib/honeybadger/client.ex
+++ b/lib/honeybadger/client.ex
@@ -65,7 +65,7 @@ defmodule Honeybadger.Client do
     if pid = Process.whereis(__MODULE__) do
       GenServer.cast(pid, {:notice, notice})
     else
-      Logger.warn(fn ->
+      Logger.warning(fn ->
         "[Honeybadger] Unable to notify, the :honeybadger client isn't running"
       end)
     end
@@ -139,10 +139,10 @@ defmodule Honeybadger.Client do
         post_notice(url, headers, payload, hackney_opts)
 
       {:error, %Jason.EncodeError{message: message}} ->
-        Logger.warn(fn -> "[Honeybadger] Notice encoding failed: #{message}" end)
+        Logger.warning(fn -> "[Honeybadger] Notice encoding failed: #{message}" end)
 
       {:error, %Protocol.UndefinedError{description: message}} ->
-        Logger.warn(fn -> "[Honeybadger] Notice encoding failed: #{message}" end)
+        Logger.warning(fn -> "[Honeybadger] Notice encoding failed: #{message}" end)
     end
 
     {:noreply, state}
@@ -169,14 +169,14 @@ defmodule Honeybadger.Client do
 
       {:ok, code, _headers, ref} when code == 429 ->
         body = body_from_ref(ref)
-        Logger.warn(fn -> "[Honeybadger] API failure: #{inspect(body)}" end)
+        Logger.warning(fn -> "[Honeybadger] API failure: #{inspect(body)}" end)
 
       {:ok, code, _headers, ref} when code in 400..599 ->
         body = body_from_ref(ref)
-        Logger.warn(fn -> "[Honeybadger] API failure: #{inspect(body)}" end)
+        Logger.warning(fn -> "[Honeybadger] API failure: #{inspect(body)}" end)
 
       {:error, reason} ->
-        Logger.warn(fn -> "[Honeybadger] connection error: #{inspect(reason)}" end)
+        Logger.warning(fn -> "[Honeybadger] connection error: #{inspect(reason)}" end)
     end
   end
 
diff --git a/mix.exs b/mix.exs
index 08205c1..cabde50 100644
--- a/mix.exs
+++ b/mix.exs
@@ -8,12 +8,14 @@ defmodule Honeybadger.Mixfile do
     [
       app: :honeybadger,
       version: @version,
-      elixir: "~> 1.7",
+      elixir: "~> 1.11",
       consolidate_protocols: Mix.env() != :test,
       build_embedded: Mix.env() == :prod,
       start_permanent: Mix.env() == :prod,
+      aliases: aliases(),
       deps: deps(),
       elixirc_paths: elixirc_paths(Mix.env()),
+      preferred_cli_env: ["test.ci": :test],
 
       # Hex
       package: package(),
@@ -51,7 +53,7 @@ defmodule Honeybadger.Mixfile do
 
   def application do
     [
-      applications: [:hackney, :logger, :jason, :telemetry],
+      extra_applications: [:logger],
       env: [
         api_key: {:system, "HONEYBADGER_API_KEY"},
         app: nil,
@@ -108,4 +110,17 @@ defmodule Honeybadger.Mixfile do
       }
     ]
   end
+
+  defp aliases do
+    [
+      "deps.ci": [
+        "deps.get --only test",
+        "cmd --cd dummy/mixapp mix deps.get --only test"
+      ],
+      "test.ci": [
+        "test --raise",
+        "cmd --cd dummy/mixapp mix test --raise"
+      ]
+    ]
+  end
 end


Test patch:
diff --git a/config/test.exs b/config/test.exs
deleted file mode 100644
index 85b3157..0000000
--- a/config/test.exs
+++ /dev/null
@@ -1,10 +0,0 @@
-import Config
-
-config :honeybadger,
-  environment_name: :test,
-  api_key: "abc123",
-  origin: "http://localhost:4444"
-
-config :ex_unit,
-  assert_receive_timeout: 400,
-  refute_receive_timeout: 200
diff --git a/test/honeybadger/backtrace_test.exs b/test/honeybadger/backtrace_test.exs
index d272f5e..f3eb55b 100644
--- a/test/honeybadger/backtrace_test.exs
+++ b/test/honeybadger/backtrace_test.exs
@@ -7,9 +7,9 @@ defmodule Honeybadger.BacktraceTest do
     stacktrace = [
       {:erlang, :some_func, [{:ok, 123}], []},
       {Honeybadger, :notify, [%RuntimeError{message: "error"}, %{a: 1}, [:a, :b]],
-       [file: 'lib/honeybadger.ex', line: 38]},
+       [file: ~c"lib/honeybadger.ex", line: 38]},
       {Honeybadger.Backtrace, :from_stacktrace, 1,
-       [file: 'lib/honeybadger/backtrace.ex', line: 4, error_info: %{module: :erl_erts_errors}]}
+       [file: ~c"lib/honeybadger/backtrace.ex", line: 4, error_info: %{module: :erl_erts_errors}]}
     ]
 
     with_config([filter_args: false], fn ->
diff --git a/test/honeybadger/breadcrumbs/collector_test.exs b/test/honeybadger/breadcrumbs/collector_test.exs
index 2a2087e..adf7b66 100644
--- a/test/honeybadger/breadcrumbs/collector_test.exs
+++ b/test/honeybadger/breadcrumbs/collector_test.exs
@@ -1,5 +1,5 @@
 defmodule Honeybadger.Breadcrumbs.CollectorTest do
-  use Honeybadger.Case, async: true
+  use Honeybadger.Case
 
   alias Honeybadger.Breadcrumbs.{Collector, Breadcrumb}
 
@@ -13,12 +13,7 @@ defmodule Honeybadger.Breadcrumbs.CollectorTest do
   end
 
   test "runs metadata through sanitizer" do
-    bc1 =
-      Breadcrumb.new("test1",
-        metadata: %{
-          key1: %{key2: 12}
-        }
-      )
+    bc1 = Breadcrumb.new("test1", metadata: %{key1: %{key2: 12}})
 
     Collector.add(bc1)
 
diff --git a/test/fingerprint_adapter_test.exs b/test/honeybadger/fingerprint_adapter_test.exs
similarity index 100%
rename from test/fingerprint_adapter_test.exs
rename to test/honeybadger/fingerprint_adapter_test.exs
diff --git a/test/honeybadger/json_test.exs b/test/honeybadger/json_test.exs
index 34aba56..5e5629f 100644
--- a/test/honeybadger/json_test.exs
+++ b/test/honeybadger/json_test.exs
@@ -35,7 +35,7 @@ defmodule Honeybadger.JSONTest do
         |> Notice.new(%{context: %{a: map, b: [map], c: [map, map]}}, [])
         |> Jason.encode()
 
-      assert custom_encoded == jason_encoded
+      assert Jason.decode!(custom_encoded) == Jason.decode!(jason_encoded)
     end
 
     test "handles values requring inspection" do
diff --git a/test/honeybadger/notice_test.exs b/test/honeybadger/notice_test.exs
index 88b5944..c5a9686 100644
--- a/test/honeybadger/notice_test.exs
+++ b/test/honeybadger/notice_test.exs
@@ -17,7 +17,7 @@ defmodule Honeybadger.NoticeTest do
     }
 
     metadata = %{plug_env: plug_env, tags: [:test], context: %{user_id: 1, account_id: 1}}
-    stack = [{Kernel, :+, [1], [file: 'lib/elixir/lib/kernel.ex', line: 321]}]
+    stack = [{Kernel, :+, [1], [file: ~c"lib/elixir/lib/kernel.ex", line: 321]}]
 
     notice = Notice.new(exception, metadata, stack)
 
diff --git a/test/integration_test.exs b/test/integration_test.exs
deleted file mode 100644
index bd5001e..0000000
--- a/test/integration_test.exs
+++ /dev/null
@@ -1,18 +0,0 @@
-defmodule Honeybadger.IntegrationTest do
-  use Honeybadger.Case
-  @tag timeout: 2 * 60_000
-  test "mix app integration tests" do
-    IO.puts("\n====================\nmix app integration tests")
-
-    assert exec(["mix", ["deps.get"], [cd: "./dummy/mixapp"]]) == 0
-    assert exec(["mix", ["test"], [cd: "./dummy/mixapp"]]) == 0
-
-    IO.puts("====================")
-  end
-
-  defp exec(args) do
-    {out, exit_code} = apply(System, :cmd, args)
-    IO.puts(out)
-    exit_code
-  end
-end
diff --git a/test/test_helper.exs b/test/test_helper.exs
index 2039393..5e8554e 100644
--- a/test/test_helper.exs
+++ b/test/test_helper.exs
@@ -1,5 +1,17 @@
 Logger.remove_backend(:console)
 
+Application.put_all_env(
+  ex_unit: [
+    assert_receive_timeout: 400,
+    refute_receive_timeout: 200
+  ],
+  honeybadger: [
+    environment_name: :test,
+    api_key: "abc123",
+    origin: "http://localhost:4444"
+  ]
+)
+
 ExUnit.start(assert_receive_timeout: 1000, refute_receive_timeout: 1000)
 
 defmodule Honeybadger.Case do