Skip to content

Commit 2ae27f2

Browse files
binarinmergify[bot]
authored andcommitted
Fix all dependencies for the dialyzer
This is the latest commit in the series, it fixes (almost) all the problems with missing and circular dependencies for typing. The only 2 unsolved problems are: - `lg` dependency for `rabbit` - the problem is that it's the only dependency that contains NIF. And there is no way to make dialyzer ignore it - looks like unknown check is not suppressable by dialyzer directives. In the future making `lg` a proper dependency can be a good thing anyway. - some missing elixir function in `rabbitmq_cli` (CSV, JSON and logging related). - `eetcd` dependency for `rabbitmq_peer_discovery_etcd` - this one uses sub-directories in `src/`, which confuses dialyzer (or our bazel machinery is not able to properly handle it). I've tried the latest rules_erlang which flattens directory for .beam files, but it wasn't enough for dialyzer - it wasn't able to find core erlang files. This is a niche plugin and an unusual dependency, so probably not worth investigating further. (cherry picked from commit 949b535) (cherry picked from commit 3a3ff30) # Conflicts: # deps/rabbit/BUILD.bazel # deps/rabbit/src/rabbit_access_control.erl # deps/rabbit/src/rabbit_exchange.erl # deps/rabbit_common/src/rabbit_misc.erl # deps/rabbitmq_consistent_hash_exchange/BUILD.bazel # deps/rabbitmq_mqtt/BUILD.bazel
1 parent 0784b02 commit 2ae27f2

File tree

27 files changed

+177
-72
lines changed

27 files changed

+177
-72
lines changed

deps/rabbit/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ load(
1010
"rabbitmq_integration_suite",
1111
"rabbitmq_suite",
1212
"rabbitmq_test_helper",
13+
"without",
1314
)
1415
load(":bats.bzl", "bats")
1516

@@ -213,7 +214,8 @@ plt(
213214
)
214215

215216
dialyze(
216-
dialyzer_opts = RABBITMQ_DIALYZER_OPTS,
217+
# A few `lg` functions are unknown
218+
dialyzer_opts = without("-Wunknown", RABBITMQ_DIALYZER_OPTS),
217219
plt = ":base_plt",
218220
)
219221

@@ -519,9 +521,12 @@ rabbitmq_suite(
519521
additional_srcs = [
520522
"test/mirrored_supervisor_SUITE_gs.erl",
521523
],
524+
<<<<<<< HEAD
522525
deps = [
523526
"//deps/rabbit_common:erlang_app",
524527
],
528+
=======
529+
>>>>>>> 3a3ff308aa (Fix all dependencies for the dialyzer)
525530
)
526531

527532
rabbitmq_suite(

deps/rabbit/apps/rabbitmq_prelaunch/BUILD.bazel

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ load("@rules_erlang//:xref2.bzl", "xref")
22
load("@rules_erlang//:dialyze.bzl", "dialyze", "plt")
33
load(
44
"//:rabbitmq.bzl",
5-
"RABBITMQ_DIALYZER_OPTS",
65
"APP_VERSION",
6+
"RABBITMQ_DIALYZER_OPTS",
77
"rabbitmq_app",
88
"rabbitmq_suite",
99
)
@@ -41,7 +41,10 @@ xref(
4141

4242
plt(
4343
name = "base_plt",
44-
apps = ["runtime_tools", "eunit"],
44+
apps = [
45+
"runtime_tools",
46+
"eunit",
47+
],
4548
plt = "//:base_plt",
4649
deps = DEPS + RUNTIME_DEPS + [
4750
"@systemd//:erlang_app",
@@ -50,8 +53,8 @@ plt(
5053
)
5154

5255
dialyze(
53-
plt = ":base_plt",
5456
dialyzer_opts = RABBITMQ_DIALYZER_OPTS,
57+
plt = ":base_plt",
5558
)
5659

5760
suites = [

deps/rabbit/src/rabbit_access_control.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616

1717
%%----------------------------------------------------------------------------
1818

19+
<<<<<<< HEAD
1920
-export_type([permission_atom/0]).
2021

2122
-type permission_atom() :: 'configure' | 'read' | 'write'.
2223

2324
%%----------------------------------------------------------------------------
2425

26+
=======
27+
>>>>>>> 3a3ff308aa (Fix all dependencies for the dialyzer)
2528
-spec check_user_pass_login
2629
(rabbit_types:username(), rabbit_types:password()) ->
2730
{'ok', rabbit_types:user()} |
@@ -179,7 +182,7 @@ create_vhost_access_authz_data(PeerAddr, Context) ->
179182
maps:merge(PeerAddr, Context).
180183

181184
-spec check_resource_access
182-
(rabbit_types:user(), rabbit_types:r(atom()), permission_atom(), rabbit_types:authz_context()) ->
185+
(rabbit_types:user(), rabbit_types:r(atom()), rabbit_types:permission_atom(), rabbit_types:authz_context()) ->
183186
'ok' | rabbit_types:channel_exit().
184187

185188
check_resource_access(User, R = #resource{kind = exchange, name = <<"">>},

deps/rabbit/src/rabbit_channel.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227

228228
-export_type([channel_number/0]).
229229

230-
-type channel_number() :: non_neg_integer().
230+
-type channel_number() :: rabbit_types:channel_number().
231231

232232
-export_type([channel/0]).
233233

deps/rabbit/src/rabbit_exchange.erl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@
2222
%%----------------------------------------------------------------------------
2323

2424
-export_type([name/0, type/0]).
25+
<<<<<<< HEAD
2526

2627
-type name() :: rabbit_types:r('exchange').
2728
-type type() :: atom().
29+
=======
30+
-type name() :: rabbit_types:exchange_name().
31+
-type type() :: rabbit_types:exchange_type().
32+
>>>>>>> 3a3ff308aa (Fix all dependencies for the dialyzer)
2833
-type fun_name() :: atom().
2934

3035
%%----------------------------------------------------------------------------

deps/rabbit/src/rabbit_guid.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
-export_type([guid/0]).
2727

28-
-type guid() :: binary().
28+
-type guid() :: rabbit_types:guid().
2929

3030
%%----------------------------------------------------------------------------
3131

deps/rabbit/src/rabbit_router.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
-export_type([routing_key/0, match_result/0]).
1717

18-
-type routing_key() :: binary().
18+
-type routing_key() :: rabbit_types:routing_key().
1919
-type match_result() :: [rabbit_types:binding_destination()].
2020

2121
%%----------------------------------------------------------------------------

deps/rabbit/src/vhost.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
-define(record_version, vhost_v2).
3636

37-
-type(name() :: binary()).
37+
-type(name() :: rabbit_types:vhost()).
3838

3939
-type(metadata_key() :: atom()).
4040

deps/rabbit_common/BUILD.bazel

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ load("@rules_erlang//:xref2.bzl", "xref")
22
load("@rules_erlang//:dialyze.bzl", "dialyze", "plt")
33
load(
44
"//:rabbitmq.bzl",
5+
"RABBITMQ_DIALYZER_OPTS",
56
"assert_suites",
67
"rabbitmq_app",
78
"rabbitmq_suite",
@@ -55,6 +56,7 @@ RUNTIME_DEPS = [
5556
"@thoas//:erlang_app",
5657
"@recon//:erlang_app",
5758
"@credentials_obfuscation//:erlang_app",
59+
"@ranch//:erlang_app",
5860
]
5961

6062
APP_NAME = "rabbit_common"
@@ -89,6 +91,8 @@ EXTRA_APPS = [
8991
"syntax_tools",
9092
"tools",
9193
"xmerl",
94+
"runtime_tools",
95+
"os_mon",
9296
]
9397

9498
rabbitmq_app(
@@ -106,23 +110,17 @@ rabbitmq_app(
106110
runtime_deps = RUNTIME_DEPS,
107111
)
108112

109-
xref(
110-
additional_libs = [
111-
"@ranch//:erlang_app",
112-
],
113-
)
113+
xref()
114114

115115
plt(
116116
name = "base_plt",
117-
apps = [
118-
"mnesia",
119-
"crypto",
120-
"ssl",
121-
] + EXTRA_APPS,
117+
apps = EXTRA_APPS + ["mnesia"],
122118
plt = "//:base_plt",
119+
deps = RUNTIME_DEPS,
123120
)
124121

125122
dialyze(
123+
dialyzer_opts = RABBITMQ_DIALYZER_OPTS,
126124
plt = ":base_plt",
127125
)
128126

deps/rabbit_common/src/rabbit_authz_backend.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
%% Something went wrong. Log and die.
5151
-callback check_resource_access(rabbit_types:auth_user(),
5252
rabbit_types:r(atom()),
53-
rabbit_access_control:permission_atom(),
53+
rabbit_types:permission_atom(),
5454
rabbit_types:authz_context()) ->
5555
boolean() | {'error', any()}.
5656

@@ -63,7 +63,7 @@
6363
%% Something went wrong. Log and die.
6464
-callback check_topic_access(rabbit_types:auth_user(),
6565
rabbit_types:r(atom()),
66-
rabbit_access_control:permission_atom(),
66+
rabbit_types:permission_atom(),
6767
rabbit_types:topic_access_context()) ->
6868
boolean() | {'error', any()}.
6969

0 commit comments

Comments
 (0)