diff --git a/.github/workflows/ci-lua.yml b/.github/workflows/ci-lua.yml new file mode 100644 index 0000000000..123c088d9d --- /dev/null +++ b/.github/workflows/ci-lua.yml @@ -0,0 +1,26 @@ +name: Lua CI + +on: [pull_request] + +jobs: + luacheck: + name: Luacheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install luarocks + run: sudo apt-get --install-recommends -y install luarocks + + - name: Install luacheck + run: sudo luarocks install luacheck + + - name: Check lua codes + run: | + set -o pipefail + luacheck -q -gur -i 581 --no-max-line-length --no-color --formatter plain $(find -name '*.lua') | awk -F: ' + { + print $0 + printf "::warning file=%s,line=%s,col=%s::%s\n", $1, $2, $3, $4 + } + ' diff --git a/resources/prosody-plugins/luajwtjitsi.lib.lua b/resources/prosody-plugins/luajwtjitsi.lib.lua index bbd383bcef..81d3e25c43 100644 --- a/resources/prosody-plugins/luajwtjitsi.lib.lua +++ b/resources/prosody-plugins/luajwtjitsi.lib.lua @@ -239,7 +239,7 @@ function M.verify(token, expectedAlgo, key, acceptedIssuers, acceptedAudiences) return nil, "'iss' claim is missing"; end if not verify_claim(issClaim, acceptedIssuers) then - return nil, "invalid 'iss' claim"; + return nil, "invalid 'iss' claim"; end end @@ -249,7 +249,7 @@ function M.verify(token, expectedAlgo, key, acceptedIssuers, acceptedAudiences) return nil, "'aud' claim is missing"; end if not verify_claim(audClaim, acceptedAudiences) then - return nil, "invalid 'aud' claim"; + return nil, "invalid 'aud' claim"; end end diff --git a/resources/prosody-plugins/mod_auth_token.lua b/resources/prosody-plugins/mod_auth_token.lua index b9f7efa7ea..da579f0e2c 100644 --- a/resources/prosody-plugins/mod_auth_token.lua +++ b/resources/prosody-plugins/mod_auth_token.lua @@ -102,7 +102,7 @@ function provider.get_sasl_handler(session) self.username = session1.username; break; end - end + end else self.username = message; end diff --git a/resources/prosody-plugins/mod_muc_allowners.lua b/resources/prosody-plugins/mod_muc_allowners.lua index 1b16642fa3..c4be39d10c 100644 --- a/resources/prosody-plugins/mod_muc_allowners.lua +++ b/resources/prosody-plugins/mod_muc_allowners.lua @@ -80,6 +80,8 @@ module:hook("muc-occupant-pre-join", function (event) return; end + -- FIX ME: luacheck warning 581 + -- not (x == y)' can be replaced by 'x ~= y' (if neither side is a table or NaN) if not (subdomain == session.jitsi_meet_context_group) then module:log('debug', 'skip allowners for auth user and non matching room subdomain: %s, jwt subdomain: %s', subdomain, session.jitsi_meet_context_group); diff --git a/resources/prosody-plugins/mod_muc_call.lua b/resources/prosody-plugins/mod_muc_call.lua index 0acf4dbc31..b977433592 100644 --- a/resources/prosody-plugins/mod_muc_call.lua +++ b/resources/prosody-plugins/mod_muc_call.lua @@ -58,6 +58,8 @@ module:hook( "muc-broadcast-presence", function (event) -- Detect if the presence is for a poltergeist or not. + -- FIX ME: luacheck warning 581 + -- not (x == y)' can be replaced by 'x ~= y' (if neither side is a table or NaN) if not (jid.bare(event.occupant.jid) == poltergeist_component) then return end diff --git a/resources/prosody-plugins/mod_muc_census.lua b/resources/prosody-plugins/mod_muc_census.lua index ca2e01858c..5b466e6228 100644 --- a/resources/prosody-plugins/mod_muc_census.lua +++ b/resources/prosody-plugins/mod_muc_census.lua @@ -11,9 +11,9 @@ -- ... -- ] -- } --- +-- -- to activate, add "muc_census" to the modules_enabled table in prosody.cfg.lua --- +-- -- warning: this module is unprotected and intended for server admin use only. -- when enabled, make sure to secure the endpoint at the web server or via -- network filters diff --git a/resources/prosody-plugins/mod_reservations.lua b/resources/prosody-plugins/mod_reservations.lua index 6b74bc26ab..84abfbf48f 100644 --- a/resources/prosody-plugins/mod_reservations.lua +++ b/resources/prosody-plugins/mod_reservations.lua @@ -252,7 +252,7 @@ end function RoomReservation:enqueue_or_route_event(event) if self.meta.status == STATUS.PENDING then table.insert(self.pending_events, event) - if not self.api_call_triggered == true then + if self.api_call_triggered ~= true then self:call_api_create_conference(); end else diff --git a/resources/prosody-plugins/mod_roster_command.lua b/resources/prosody-plugins/mod_roster_command.lua index dc6e67ec47..985a8c2511 100644 --- a/resources/prosody-plugins/mod_roster_command.lua +++ b/resources/prosody-plugins/mod_roster_command.lua @@ -161,5 +161,4 @@ function module.command(arg) warn("Unknown command: %s", command); return 1; end - return 0; end diff --git a/resources/prosody-plugins/mod_speakerstats_component.lua b/resources/prosody-plugins/mod_speakerstats_component.lua index 94dc8dd72a..5b2c646bf2 100644 --- a/resources/prosody-plugins/mod_speakerstats_component.lua +++ b/resources/prosody-plugins/mod_speakerstats_component.lua @@ -124,7 +124,7 @@ function on_message(event) local faceLandmarks = room.speakerStats[occupant.jid].faceLandmarks; table.insert(faceLandmarks, { - faceExpression = newFaceLandmarks.attr.faceExpression, + faceExpression = newFaceLandmarks.attr.faceExpression, timestamp = tonumber(newFaceLandmarks.attr.timestamp), duration = tonumber(newFaceLandmarks.attr.duration), }) diff --git a/resources/prosody-plugins/util.lib.lua b/resources/prosody-plugins/util.lib.lua index 5609a7cd5a..f35c451d6a 100644 --- a/resources/prosody-plugins/util.lib.lua +++ b/resources/prosody-plugins/util.lib.lua @@ -286,7 +286,7 @@ end --- retry @param retry number of times -- @param url endpoint to be called -- @param retry nr of retries, if retry is --- @param auth_token value to be passed as auth Bearer +-- @param auth_token value to be passed as auth Bearer -- nil there will be no retries -- @returns result of the http call or nil if -- the external call failed after the last retry