Skip to content

Commit 0e7b977

Browse files
committed
fix :timer.foo regression
1 parent f9d5179 commit 0e7b977

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/style/deprecations.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ defmodule Styler.Style.Deprecations do
6161
if Version.match?(System.version(), ">= 1.17.0-dev") do
6262
@to_timeout_vsn Version.parse!("1.17.0-dev")
6363
# `unit` is plural for erlang, but single_node style rewrites plural to_timeouts into singulars
64-
defp style({{:., _, [{:__block__, _, [:timer]}, unit]}, fm, [x]} = node) do
64+
defp style({{:., _, [{:__block__, _, [:timer]}, unit]}, fm, [x]} = node) when unit in ~w(hours minutes seconds)a do
6565
if Styler.Config.version_compatible?(@to_timeout_vsn),
6666
do: {:to_timeout, fm, [[{{:__block__, [format: :keyword, line: fm[:line]], [unit]}, x}]]},
6767
else: node

test/style/deprecations_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,10 @@ defmodule Styler.Style.DeprecationsTest do
151151
test "combined with to_timeout improvements" do
152152
assert_style ":timer.minutes(60 * 4)", "to_timeout(hour: 4)"
153153
end
154+
155+
test "regression: doesn't touch other timer functions" do
156+
assert_style ":timer.sleep(1000)"
157+
assert_style ":timer.tc(fn -> :ok end)"
158+
end
154159
end
155160
end

0 commit comments

Comments
 (0)