Skip to content

Commit 9222e3b

Browse files
Merge pull request #13351 from rabbitmq/cli-module-attribute-otp28
CLI: Don't use regex as module attributes
2 parents 0773b56 + 7e8ecc9 commit 9222e3b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/core/command_modules.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule RabbitMQ.CLI.Core.CommandModules do
1111

1212
import RabbitMQ.CLI.Core.CodePath
1313

14-
@commands_ns ~r/RabbitMQ.CLI.(.*).Commands/
14+
@commands_ns ~S"RabbitMQ.CLI.(.*).Commands"
1515

1616
def module_map(opts \\ %{}) do
1717
Application.get_env(:rabbitmqctl, :commands) || load(opts)
@@ -130,7 +130,7 @@ defmodule RabbitMQ.CLI.Core.CommandModules do
130130
end
131131

132132
defp make_module_map(modules, scope) when modules != nil do
133-
commands_ns = Regex.recompile!(@commands_ns)
133+
commands_ns = Regex.compile!(@commands_ns)
134134

135135
modules
136136
|> Enum.filter(fn mod ->
@@ -212,7 +212,7 @@ defmodule RabbitMQ.CLI.Core.CommandModules do
212212
defp command_scopes(cmd) do
213213
case CommandBehaviour.scopes(cmd) do
214214
nil ->
215-
Regex.recompile!(@commands_ns)
215+
Regex.compile!(@commands_ns)
216216
|> Regex.run(to_string(cmd), capture: :all_but_first)
217217
|> List.first()
218218
|> to_snake_case

deps/rabbitmq_cli/lib/rabbitmq/cli/core/os_pid.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
defmodule RabbitMQ.CLI.Core.OsPid do
88
@external_process_check_interval 1000
99

10-
@pid_regex ~r/^\s*(?<pid>\d+)/
10+
@pid_regex ~S"^\s*(?<pid>\d+)"
1111

1212
#
1313
# API
@@ -27,7 +27,7 @@ defmodule RabbitMQ.CLI.Core.OsPid do
2727
def read_pid_from_file(pidfile_path, should_wait) do
2828
case {:file.read_file(pidfile_path), should_wait} do
2929
{{:ok, contents}, _} ->
30-
pid_regex = Regex.recompile!(@pid_regex)
30+
pid_regex = Regex.compile!(@pid_regex)
3131

3232
case Regex.named_captures(pid_regex, contents)["pid"] do
3333
# e.g. the file is empty

0 commit comments

Comments
 (0)