diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 753d4b3..adbf265 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -157,7 +157,7 @@ jobs: run: | mkdir -p priv/plts mix deps.get - # mix dialyzer --plt + mix dialyzer --plt - run: mix deps.get - run: mix clean && mix deep_clean @@ -165,4 +165,4 @@ jobs: - run: mix deps.unlock --check-unused - run: mix format --check-formatted - run: mix credo --strict - # - run: mix dialyzer --plt + - run: mix dialyzer --plt diff --git a/lib/vix/operator.ex b/lib/vix/operator.ex index 0128a5f..c94eb20 100644 --- a/lib/vix/operator.ex +++ b/lib/vix/operator.ex @@ -164,7 +164,7 @@ defmodule Vix.Operator do image?(a) && is_list(b) -> when_number_list b do - Operation.linear!(a, [1], b) + Operation.linear!(a, [1.0], b) end true -> @@ -189,7 +189,7 @@ defmodule Vix.Operator do image?(a) && is_list(b) -> when_number_list b do - Operation.linear!(a, b, [0]) + Operation.linear!(a, b, [+0.0]) end true -> @@ -212,12 +212,12 @@ defmodule Vix.Operator do is_list(a) && image?(b) -> when_number_list a do # a - b = (b * -1) + a - Operation.linear!(b, [-1], a) + Operation.linear!(b, [-1.0], a) end image?(a) && is_list(b) -> when_number_list b do - Operation.linear!(a, [1], Enum.map(b, &(-&1))) + Operation.linear!(a, [1.0], Enum.map(b, &(-&1))) end true -> @@ -241,13 +241,13 @@ defmodule Vix.Operator do when_number_list a do # a / b = (b^-1) * a = (1 / b) * a b - |> Operation.math2_const!(:VIPS_OPERATION_MATH2_POW, [-1]) - |> Operation.linear!(a, [0]) + |> Operation.math2_const!(:VIPS_OPERATION_MATH2_POW, [-1.0]) + |> Operation.linear!(a, [+0.0]) end image?(a) && is_list(b) -> when_number_list b do - Operation.linear!(a, Enum.map(b, &(1 / &1)), [0]) + Operation.linear!(a, Enum.map(b, &(1 / &1)), [+0.0]) end true -> diff --git a/lib/vix/vips/image.ex b/lib/vix/vips/image.ex index ef5ce56..6d0cd56 100644 --- a/lib/vix/vips/image.ex +++ b/lib/vix/vips/image.ex @@ -197,7 +197,7 @@ defmodule Vix.Vips.Image do end @impl Access - def pop(_image, _band, _default \\ nil) do + def pop(_image, _band) do raise ArgumentError, "pop/3 for Vix.Vips.Image is not supported." end @@ -818,7 +818,7 @@ defmodule Vix.Vips.Image do end end - @spec write_area_to_binary(t(), params :: keyword) :: {:ok, binary()} | {:error, term()} + @spec write_area_to_binary(t(), params :: keyword) :: {:ok, map} | {:error, term()} defp write_area_to_binary(%Image{ref: vips_image}, params \\ []) do params = Enum.map(~w(left top width height band_start band_count)a, fn key -> @@ -1040,7 +1040,7 @@ defmodule Vix.Vips.Image do "xoffset" => quote(do: integer()), "yoffset" => quote(do: integer()), "filename" => quote(do: String.t()), - "mode" => quote(do: Stringt.t()), + "mode" => quote(do: String.t()), "scale" => quote(do: float()), "offset" => quote(do: float()), "page-height" => quote(do: integer()), @@ -1048,7 +1048,7 @@ defmodule Vix.Vips.Image do "orientation" => quote(do: integer()), "interpretation" => quote(do: Vix.Vips.Operation.vips_interpretation()), "coding" => quote(do: Vix.Vips.Operation.vips_coding()), - "format" => quote(do: Vix.Vips.Operatoin.vips_band_format()) + "format" => quote(do: Vix.Vips.Operation.vips_band_format()) } do func_name = name |> String.replace("-", "_") |> String.to_atom() @@ -1085,7 +1085,7 @@ defmodule Vix.Vips.Image do xoffset: integer() | nil, yoffset: integer() | nil, filename: String.t() | nil, - mode: Stringt.t() | nil, + mode: String.t() | nil, scale: float() | nil, offset: float() | nil, "page-height": integer() | nil, @@ -1093,7 +1093,7 @@ defmodule Vix.Vips.Image do orientation: integer() | nil, interpretation: Vix.Vips.Operation.vips_interpretation() | nil, coding: Vix.Vips.Operation.vips_coding() | nil, - format: Vix.Vips.Operatoin.vips_band_format() | nil + format: Vix.Vips.Operation.vips_band_format() | nil } def headers(image) do [ @@ -1158,7 +1158,8 @@ defmodule Vix.Vips.Image do end @spec validate_matrix_list([[number]] | [number] | Range.t()) :: - {width :: non_neg_integer(), height :: non_neg_integer(), [number]} + {:ok, {width :: non_neg_integer(), height :: non_neg_integer(), [number]}} + | {:error, term} defp validate_matrix_list(list) do list = normalize_list(list) diff --git a/lib/vix/vips/mutable_operation.ex b/lib/vix/vips/mutable_operation.ex index 7ab0c79..e9edcc4 100644 --- a/lib/vix/vips/mutable_operation.ex +++ b/lib/vix/vips/mutable_operation.ex @@ -97,6 +97,7 @@ defmodule Vix.Vips.MutableOperation do ) ) if in_opt_spec == [] do + @dialyzer {:no_match, [{bang_func_name, length(req_params)}]} # operations without optional arguments def unquote(bang_func_name)(unquote_splicing(req_params)) do case __MODULE__.unquote(func_name)(unquote_splicing(req_params)) do @@ -107,6 +108,7 @@ defmodule Vix.Vips.MutableOperation do end end else + @dialyzer {:no_match, [{bang_func_name, length(req_params) + 1}]} # operations with optional arguments def unquote(bang_func_name)(unquote_splicing(req_params), optional \\ []) do case __MODULE__.unquote(func_name)(unquote_splicing(req_params), optional) do diff --git a/lib/vix/vips/operation.ex b/lib/vix/vips/operation.ex index 740ebe1..268ce5b 100644 --- a/lib/vix/vips/operation.ex +++ b/lib/vix/vips/operation.ex @@ -77,6 +77,7 @@ defmodule Vix.Vips.Operation do ) ) if in_opt_spec == [] do + @dialyzer {:no_match, [{bang_func_name, length(req_params)}]} # operations without optional arguments def unquote(bang_func_name)(unquote_splicing(req_params)) do case __MODULE__.unquote(func_name)(unquote_splicing(req_params)) do @@ -87,6 +88,7 @@ defmodule Vix.Vips.Operation do end end else + @dialyzer {:no_match, [{bang_func_name, length(req_params) + 1}]} # operations with optional arguments def unquote(bang_func_name)(unquote_splicing(req_params), optional \\ []) do case __MODULE__.unquote(func_name)(unquote_splicing(req_params), optional) do