Skip to content

Commit f5f171f

Browse files
committed
Fix regexp change in OTP 28 that deprecated regexp module attributes
See elixir-lang/elixir#14381 for details. With Elixir 1.19, this fixes the following warning: ``` warning: storing and reading regexes from module attributes is deprecated, inline the regex inside the function definition instead │ 162 │ Regex.match?(@sapi_version_regex, answer) -> │ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ │ └─ lib/grizzly/zwave_firmware.ex:162: Grizzly.ZWaveFirmware.zwave_module_version/1 ```
1 parent e636421 commit f5f171f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/grizzly/zwave_firmware.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ defmodule Grizzly.ZWaveFirmware do
148148
|> Enum.find(&UpgradeSpec.applies?(&1, current_version))
149149
end
150150

151-
@sapi_version_regex ~r/Chip type: (?<chip_type>\d+).*SDK:\s*(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/m
152-
153151
@doc false
154152
@spec zwave_module_version(Options.t()) :: Version.t() | nil
155153
def zwave_module_version(opts) do
@@ -158,10 +156,13 @@ defmodule Grizzly.ZWaveFirmware do
158156
{answer, _} = zw_programmer(opts, ["-t"])
159157
Logger.debug("[Grizzly] Extracting current Z-Wave firmware version from #{inspect(answer)}")
160158

159+
sapi_version_regex =
160+
~r/Chip type: (?<chip_type>\d+).*SDK:\s*(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/m
161+
161162
cond do
162-
Regex.match?(@sapi_version_regex, answer) ->
163+
Regex.match?(sapi_version_regex, answer) ->
163164
%{"major" => major_s, "minor" => minor_s, "patch" => patch_s} =
164-
Regex.named_captures(@sapi_version_regex, answer)
165+
Regex.named_captures(sapi_version_regex, answer)
165166

166167
Logger.info("[Grizzly] Current Z-Wave firmware version: #{major_s}.#{minor_s}.#{patch_s}")
167168

0 commit comments

Comments
 (0)