From 7c83978aa3a849a30fd063b1d5c3c80ea9432ad1 Mon Sep 17 00:00:00 2001 From: Frank Hunleth Date: Sun, 12 Jan 2025 15:06:01 -0500 Subject: [PATCH 1/3] Bump dependencies and test with latest Elixir --- .github/workflows/ci.yml | 14 ++++++++++---- mix.lock | 29 +++++++++++++++-------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5e65ba..cfcc0bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,10 @@ jobs: otp: 25 - elixir: 1.16 otp: 26 + - elixir: 1.17 + otp: 27 + - elixir: 1.18 + otp: 27 steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.11.0 @@ -59,10 +63,8 @@ jobs: strategy: matrix: include: - - elixir: 1.15 - otp: 25 - - elixir: 1.16 - otp: 26 + - elixir: 1.18 + otp: 27 steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.11.0 @@ -113,6 +115,10 @@ jobs: otp: 25 - elixir: 1.16 otp: 26 + - elixir: 1.17 + otp: 27 + - elixir: 1.18 + otp: 27 steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.11.0 diff --git a/mix.lock b/mix.lock index 4ae08b0..9e70cef 100644 --- a/mix.lock +++ b/mix.lock @@ -1,18 +1,19 @@ %{ "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, - "circuits_i2c": {:hex, :circuits_i2c, "2.0.2", "ed1bac41cca0b777e11e2105c08dc7cad67a221e0d7eec1680a644eba677f9f5", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "b8cf6ef783f9184bf4e45a1a4fa0a72523aa4e3c2fa980f94a45336c92d95178"}, - "credo": {:hex, :credo, "1.7.3", "05bb11eaf2f2b8db370ecaa6a6bda2ec49b2acd5e0418bc106b73b07128c0436", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "35ea675a094c934c22fb1dca3696f3c31f2728ae6ef5a53b5d648c11180a4535"}, - "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, - "elixir_make": {:hex, :elixir_make, "0.7.8", "505026f266552ee5aabca0b9f9c229cbb496c689537c9f922f3eb5431157efc7", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "7a71945b913d37ea89b06966e1342c85cfe549b15e6d6d081e8081c493062c07"}, - "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.31.1", "8a2355ac42b1cc7b2379da9e40243f2670143721dd50748bf6c3b1184dae2089", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "3178c3a407c557d8343479e1ff117a96fd31bafe52a039079593fb0524ef61b0"}, - "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, - "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, - "makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"}, - "makeup_erlang": {:hex, :makeup_erlang, "0.1.3", "d684f4bac8690e70b06eb52dad65d26de2eefa44cd19d64a8095e1417df7c8fd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "b78dc853d2e670ff6390b605d807263bf606da3c82be37f9d7f68635bd886fc9"}, - "mix_test_watch": {:hex, :mix_test_watch, "1.1.1", "eee6fc570d77ad6851c7bc08de420a47fd1e449ef5ccfa6a77ef68b72e7e51ad", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "f82262b54dee533467021723892e15c3267349849f1f737526523ecba4e6baae"}, - "mox": {:hex, :mox, "1.1.0", "0f5e399649ce9ab7602f72e718305c0f9cdc351190f72844599545e4996af73c", [:mix], [], "hexpm", "d44474c50be02d5b72131070281a5d3895c0e7a95c780e90bc0cfe712f633a13"}, + "circuits_i2c": {:hex, :circuits_i2c, "2.0.6", "78f69c24e4dcc83cd6806e29810540dfb9f6686f290852e34cc020199efd6c7c", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "9b21289b5d350b6b64bf40ddd15d499ee5a04e6353d8de8bc839c615b555b96b"}, + "credo": {:hex, :credo, "1.7.11", "d3e805f7ddf6c9c854fd36f089649d7cf6ba74c42bc3795d587814e3c9847102", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "56826b4306843253a66e47ae45e98e7d284ee1f95d53d1612bb483f88a8cf219"}, + "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.42", "f23d856f41919f17cd06a493923a722d87a2d684f143a1e663c04a2b93100682", [:mix], [], "hexpm", "6915b6ca369b5f7346636a2f41c6a6d78b5af419d61a611079189233358b8b8b"}, + "elixir_make": {:hex, :elixir_make, "0.9.0", "6484b3cd8c0cee58f09f05ecaf1a140a8c97670671a6a0e7ab4dc326c3109726", [:mix], [], "hexpm", "db23d4fd8b757462ad02f8aa73431a426fe6671c80b200d9710caf3d1dd0ffdb"}, + "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, + "ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"}, + "file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, + "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, + "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, + "mix_test_watch": {:hex, :mix_test_watch, "1.2.0", "1f9acd9e1104f62f280e30fc2243ae5e6d8ddc2f7f4dc9bceb454b9a41c82b42", [:mix], [{:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "278dc955c20b3fb9a3168b5c2493c2e5cffad133548d307e0a50c7f2cfbf34f6"}, + "mox": {:hex, :mox, "1.2.0", "a2cd96b4b80a3883e3100a221e8adc1b98e4c3a332a8fc434c39526babafd5b3", [:mix], [{:nimble_ownership, "~> 1.0", [hex: :nimble_ownership, repo: "hexpm", optional: false]}], "hexpm", "c7b92b3cc69ee24a7eeeaf944cd7be22013c52fcb580c1f33f50845ec821089a"}, + "nimble_ownership": {:hex, :nimble_ownership, "1.0.1", "f69fae0cdd451b1614364013544e66e4f5d25f36a2056a9698b793305c5aa3a6", [:mix], [], "hexpm", "3825e461025464f519f3f3e4a1f9b68c47dc151369611629ad08b636b73bb22d"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, } From b3345a3f9164b12f6e631bfb81e24f0c91abaf1e Mon Sep 17 00:00:00 2001 From: Frank Hunleth Date: Sun, 12 Jan 2025 15:07:51 -0500 Subject: [PATCH 2/3] Fix deprecation warning when running tests --- .github/workflows/ci.yml | 2 +- test/test_helper.exs | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfcc0bc..94f4f75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,4 +147,4 @@ jobs: key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('mix.lock') }} - name: Run test - run: mix test --trace --slowest 10 + run: mix test --warnings-as-errors --trace --slowest 10 diff --git a/test/test_helper.exs b/test/test_helper.exs index 88ac840..869559e 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,4 +1 @@ -# Always warning as errors -Code.put_compiler_option(:warnings_as_errors, true) - ExUnit.start() From 82734aef51f4aace07904e9da1b27b7d19ce31c3 Mon Sep 17 00:00:00 2001 From: Frank Hunleth Date: Sun, 12 Jan 2025 15:24:19 -0500 Subject: [PATCH 3/3] Update Dialyzer for latest Erlang; Fix most issues --- config/config.exs | 4 +++- lib/sgp40/comm.ex | 6 +++--- lib/sgp40/voc_index.ex | 2 +- mix.exs | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/config/config.exs b/config/config.exs index 33eff45..618fd08 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,3 +1,5 @@ import Config -config :sgp40, transport_mod: SGP40.MockTransport +if Mix.env() == :test do + config :sgp40, transport_mod: SGP40.MockTransport +end diff --git a/lib/sgp40/comm.ex b/lib/sgp40/comm.ex index 771a438..b266f9a 100644 --- a/lib/sgp40/comm.ex +++ b/lib/sgp40/comm.ex @@ -10,7 +10,7 @@ defmodule SGP40.Comm do @transport_mod Application.compile_env(:sgp40, :transport_mod, SGP40.Transport.I2C) - @spec serial_id(pid) :: {:ok, binary} + @spec serial_id(any) :: {:ok, binary} | {:error, any()} def serial_id(transport) do case @transport_mod.write_read(transport, @cmd_get_serial_id, 3) do {:ok, serial_id_binary} -> {:ok, Base.encode16(serial_id_binary)} @@ -18,7 +18,7 @@ defmodule SGP40.Comm do end end - @spec featureset(any) :: {:ok, byte} + @spec featureset(any) :: {:ok, byte} | {:error, any()} def featureset(transport) do case @transport_mod.write_read(transport, @cmd_get_featureset, 1) do {:ok, <>} -> {:ok, featureset} @@ -30,7 +30,7 @@ defmodule SGP40.Comm do Triggers the built-in self-test checking for integrity of both hotplate and MOX material and returns the result of this test as 2 bytes (+ 1 CRC byte). """ - @spec measure_test(pid) :: {:ok, binary} + @spec measure_test(pid) :: {:ok, binary} | {:error, any()} def measure_test(transport) do with :ok <- @transport_mod.write(transport, @cmd_measure_test), :ok <- Process.sleep(250), diff --git a/lib/sgp40/voc_index.ex b/lib/sgp40/voc_index.ex index c5dc6f5..430c0b9 100644 --- a/lib/sgp40/voc_index.ex +++ b/lib/sgp40/voc_index.ex @@ -14,7 +14,7 @@ defmodule SGP40.VocIndex do Initialize the VOC algorithm parameters. Call this once at the beginning or whenever the sensor stopped measurements. """ - @spec start_link(any) :: GenServer.on_start() + @spec start_link(keyword()) :: GenServer.on_start() def start_link(_args \\ []) do case GenServer.start_link(__MODULE__, nil, name: __MODULE__) do {:ok, pid} -> {:ok, pid} diff --git a/mix.exs b/mix.exs index bc02e2a..0e3b710 100644 --- a/mix.exs +++ b/mix.exs @@ -50,7 +50,7 @@ defmodule SGP40.MixProject do defp dialyzer() do [ - flags: [:race_conditions, :unmatched_returns, :error_handling, :underspecs] + flags: [:missing_return, :extra_return, :unmatched_returns, :error_handling, :underspecs] ] end