Skip to content

Commit

Permalink
Group if conditions in Server:initialize func
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ylobankov committed Sep 6, 2023
1 parent 9423bcd commit f162f45
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions luatest/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit f162f45

Please sign in to comment.