From e548d648eb8d3dc6df881e9b5d14ff1728c4b389 Mon Sep 17 00:00:00 2001 From: Yaroslav Lobankov Date: Tue, 5 Sep 2023 16:30:05 +0400 Subject: [PATCH] Group `if` conditions in `Server:initialize` func The conditions like if a == nil and b == nil then c = 'something' end if a == nil and b then c = 'something else' end going in a row looks a little strange. This patch groups such conditions into the following construction: if a == nil then if b == nil then c = 'something' else c = 'something else' end end --- luatest/server.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/luatest/server.lua b/luatest/server.lua index 533b46e..60a4a1a 100644 --- a/luatest/server.lua +++ b/luatest/server.lua @@ -147,11 +147,12 @@ function Server:initialize() self.http_client = http_client.new() end - if self.net_box_uri == nil and self.net_box_port == nil then - self.net_box_uri = self.build_listen_uri(self.alias, self.rs_id or self.id) - end - if self.net_box_uri == nil and self.net_box_port then - self.net_box_uri = 'localhost:' .. self.net_box_port + if self.net_box_uri == nil then + if self.net_box_port == nil then + self.net_box_uri = self.build_listen_uri(self.alias, self.rs_id or self.id) + else + self.net_box_uri = 'localhost:' .. self.net_box_port + end end self.env = utils.merge(self.env or {}, self:build_env())