From a39871f97a29fa8784970cd171f8d9033b7095a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20M=C3=A4nnchen?= Date: Thu, 15 Jan 2026 12:10:17 +0100 Subject: [PATCH 1/2] Dialyzer Setup --- .github/workflows/main.yml | 4 ++++ mix.exs | 4 +++- mix.lock | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64f3167..fcc5561 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -61,3 +61,7 @@ jobs: - name: Run tests with code coverage run: mix coveralls.github if: ${{ matrix.coverage }} + + - name: Run dialyzer + run: mix dialyzer + if: ${{ matrix.lint }} diff --git a/mix.exs b/mix.exs index 33acc47..e654958 100644 --- a/mix.exs +++ b/mix.exs @@ -41,7 +41,8 @@ defmodule Gettext.Mixfile do &(&1[:module] == Gettext.Macros and to_string(&1[:name]) =~ ~r/_noop$/), "Translation Macros": &(&1[:module] == Gettext.Macros) ] - ] + ], + dialyzer: [list_unused_filters: true, plt_add_apps: [:mix]] ] end @@ -74,6 +75,7 @@ defmodule Gettext.Mixfile do # Dev and test dependencies {:castore, "~> 1.0", only: :test}, + {:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false}, {:jason, "~> 1.0", only: :test}, {:ex_doc, "~> 0.19", only: :dev}, {:excoveralls, "~> 0.18.0", only: :test} diff --git a/mix.lock b/mix.lock index 25adaae..3be8dcc 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,8 @@ %{ "castore": {:hex, :castore, "1.0.10", "43bbeeac820f16c89f79721af1b3e092399b3a1ecc8df1a472738fd853574911", [:mix], [], "hexpm", "1b0b7ea14d889d9ea21202c43a4fa015eb913021cb535e8ed91946f4b77a8848"}, + "dialyxir": {:hex, :dialyxir, "1.4.7", "dda948fcee52962e4b6c5b4b16b2d8fa7d50d8645bbae8b8685c3f9ecb7f5f4d", [:mix], [{:erlex, ">= 0.2.8", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b34527202e6eb8cee198efec110996c25c5898f43a4094df157f8d28f27d9efe"}, "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, + "erlex": {:hex, :erlex, "0.2.8", "cd8116f20f3c0afe376d1e8d1f0ae2452337729f68be016ea544a72f767d9c12", [:mix], [], "hexpm", "9d66ff9fedf69e49dc3fd12831e12a8a37b76f8651dd21cd45fcf5561a8a7590"}, "ex_doc": {:hex, :ex_doc, "0.39.1", "e19d356a1ba1e8f8cfc79ce1c3f83884b6abfcb79329d435d4bbb3e97ccc286e", [:mix], [{:earmark_parser, "~> 1.4.44", [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", "8abf0ed3e3ca87c0847dfc4168ceab5bedfe881692f1b7c45f4a11b232806865"}, "excoveralls": {:hex, :excoveralls, "0.18.3", "bca47a24d69a3179951f51f1db6d3ed63bca9017f476fe520eb78602d45f7756", [:mix], [{:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "746f404fcd09d5029f1b211739afb8fb8575d775b21f6a3908e7ce3e640724c6"}, "expo": {:hex, :expo, "1.1.0", "f7b9ed7fb5745ebe1eeedf3d6f29226c5dd52897ac67c0f8af62a07e661e5c75", [:mix], [], "hexpm", "fbadf93f4700fb44c331362177bdca9eeb8097e8b0ef525c9cc501cb9917c960"}, From 0a2653b1e15e8921f94e8a1af52d6329f8027b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20M=C3=A4nnchen?= Date: Thu, 15 Jan 2026 12:10:39 +0100 Subject: [PATCH 2/2] Remove unreachable clause --- lib/gettext/extractor.ex | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/gettext/extractor.ex b/lib/gettext/extractor.ex index c19b6a7..284b794 100644 --- a/lib/gettext/extractor.ex +++ b/lib/gettext/extractor.ex @@ -388,11 +388,6 @@ defmodule Gettext.Extractor do end end - defp ensure_empty_msgstr!(%Message.Plural{} = message) do - raise Error, - "plural message with msgid '#{IO.iodata_to_binary(message.msgid)}' has a non-empty msgstr" - end - defp blank?(str) when not is_nil(str), do: IO.iodata_length(str) == 0 defp blank?(_), do: true