From 22808630b60dab76063c4481130f543881993801 Mon Sep 17 00:00:00 2001 From: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:49:08 +0100 Subject: [PATCH] docs: fix some annotation warnings (#4116) * move to correct folder * fix some annos * fix annos of RL player ext * as per review --- components/match2/commons/bracket_template.lua | 2 +- .../match2/commons/brkts_wiki_specific_base.lua | 1 + components/match2/commons/match_group.lua | 2 +- components/match2/test/match_test.lua | 4 ++++ .../wikis/ageofempires/match_group_input_custom.lua | 2 +- .../match2/wikis/ageofempires/match_summary.lua | 1 + .../match2/wikis/apexlegends/brkts_wikispecific.lua | 6 ++++-- components/match2/wikis/arenafps/match_legacy.lua | 1 + .../match2/wikis/rocketleague/brkts_wiki_specific.lua | 5 ++++- components/match2/wikis/trackmania/match_summary.lua | 2 +- components/match2/wikis/warcraft/match_legacy.lua | 2 +- .../wikis/rocketleague/player_ext_custom.lua | 11 ++++++++--- 12 files changed, 28 insertions(+), 11 deletions(-) rename components/{match2 => opponent}/wikis/rocketleague/player_ext_custom.lua (72%) diff --git a/components/match2/commons/bracket_template.lua b/components/match2/commons/bracket_template.lua index 69d8c92e5ad..66f13b87aa0 100644 --- a/components/match2/commons/bracket_template.lua +++ b/components/match2/commons/bracket_template.lua @@ -56,7 +56,7 @@ end ---@return Html function BracketTemplate.BracketContainer(props) return BracketDisplay.Bracket({ - bracket = MatchGroupUtil.fetchMatchGroup(props.bracketId), + bracket = MatchGroupUtil.fetchMatchGroup(props.bracketId) --[[@as MatchGroupUtilBracket]], config = Table.merge(props.config, { OpponentEntry = function() return mw.html.create('div'):addClass('brkts-opponent-entry') end, matchHasDetails = function() return false end, diff --git a/components/match2/commons/brkts_wiki_specific_base.lua b/components/match2/commons/brkts_wiki_specific_base.lua index cdcdd864e65..94930a00103 100644 --- a/components/match2/commons/brkts_wiki_specific_base.lua +++ b/components/match2/commons/brkts_wiki_specific_base.lua @@ -10,6 +10,7 @@ local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') ---@class BrktsWikiSpecific +---@field defaultIcon string? local WikiSpecificBase = {} -- called from Module:MatchGroup diff --git a/components/match2/commons/match_group.lua b/components/match2/commons/match_group.lua index 5434bd6cf2d..e1acd0f373a 100644 --- a/components/match2/commons/match_group.lua +++ b/components/match2/commons/match_group.lua @@ -72,7 +72,7 @@ function MatchGroup.Bracket(args) local parts = Array.extend( Array.map(optionsWarnings, WarningBox.display), - Array.map(bracketWarnings, WarningBox.display), + Array.map(bracketWarnings or {}, WarningBox.display), {bracketNode} ) return table.concat(Array.map(parts, tostring)) diff --git a/components/match2/test/match_test.lua b/components/match2/test/match_test.lua index fd2be881f10..b08de3eef37 100644 --- a/components/match2/test/match_test.lua +++ b/components/match2/test/match_test.lua @@ -16,7 +16,11 @@ function suite:testSplitRecordsByType() MatchTestConfig.EXPECTED_OUTPUT_AFTER_SPLIT, Match.splitRecordsByType(MatchTestConfig.EXAMPLE_MATCH)) self:assertDeepEquals( MatchTestConfig.EXPECTED_OUTPUT_AFTER_SPLIT_SC2, Match.splitRecordsByType(MatchTestConfig.EXAMPLE_MATCH_SC2)) + ---intended missmatch + ---@diagnostic disable-next-line: param-type-mismatch self:assertDeepEquals({}, Match.splitRecordsByType(nil)) + ---intended missmatch + ---@diagnostic disable-next-line: param-type-mismatch self:assertDeepEquals({}, Match.splitRecordsByType('something')) end diff --git a/components/match2/wikis/ageofempires/match_group_input_custom.lua b/components/match2/wikis/ageofempires/match_group_input_custom.lua index feddf12e95a..c63fe0451ab 100644 --- a/components/match2/wikis/ageofempires/match_group_input_custom.lua +++ b/components/match2/wikis/ageofempires/match_group_input_custom.lua @@ -328,7 +328,7 @@ function CustomMatchGroupInput._mapInput(match, mapIndex) -- Init score if match started and map info is present if not match.opponent1.autoscore and not match.opponent2.autoscore and map.map and map.map ~= 'TBD' - and match.timestamp < os.time(os.date('!*t')) + and match.timestamp < os.time(os.date('!*t') --[[@as osdateparam]]) and String.isNotEmpty(map.civs1) and String.isNotEmpty(map.civs2) then match.opponent1.autoscore = 0 match.opponent2.autoscore = 0 diff --git a/components/match2/wikis/ageofempires/match_summary.lua b/components/match2/wikis/ageofempires/match_summary.lua index a59ccf23729..3cb545ee5ec 100644 --- a/components/match2/wikis/ageofempires/match_summary.lua +++ b/components/match2/wikis/ageofempires/match_summary.lua @@ -206,6 +206,7 @@ end ---@param winner integer|string ---@param opponentIndex integer +---@param soloMode boolean ---@return Html function CustomMatchSummary._createCheckMark(winner, opponentIndex, soloMode) return mw.html.create('div') diff --git a/components/match2/wikis/apexlegends/brkts_wikispecific.lua b/components/match2/wikis/apexlegends/brkts_wikispecific.lua index 664117e997c..cbda88f87e2 100644 --- a/components/match2/wikis/apexlegends/brkts_wikispecific.lua +++ b/components/match2/wikis/apexlegends/brkts_wikispecific.lua @@ -9,9 +9,11 @@ local Lua = require('Module:Lua') local Table = require('Module:Table') -local WikiSpecific = Table.copy(Lua.import('Module:Brkts/WikiSpecific/Base')) +local BaseWikiSpecific = Lua.import('Module:Brkts/WikiSpecific/Base') + +---@class ApexlegendsBrktsWikiSpecific: BrktsWikiSpecific +local WikiSpecific = Table.copy(BaseWikiSpecific) ----@diagnostic disable-next-line: duplicate-set-field function WikiSpecific.getMatchGroupContainer(matchGroupType) return Lua.import('Module:MatchGroup/Display/Horizontallist').BracketContainer end diff --git a/components/match2/wikis/arenafps/match_legacy.lua b/components/match2/wikis/arenafps/match_legacy.lua index 3e5dba660e2..0be9a416498 100644 --- a/components/match2/wikis/arenafps/match_legacy.lua +++ b/components/match2/wikis/arenafps/match_legacy.lua @@ -55,6 +55,7 @@ end ---@param match2 table ---@return table function MatchLegacy._convertParameters(match2) + ---@type table local match = Table.filterByKey(match2, function(key) return not String.startsWith(key, 'match2') end) match.staticid = match2.match2id diff --git a/components/match2/wikis/rocketleague/brkts_wiki_specific.lua b/components/match2/wikis/rocketleague/brkts_wiki_specific.lua index a9a6bb29a9c..48c9bea239c 100644 --- a/components/match2/wikis/rocketleague/brkts_wiki_specific.lua +++ b/components/match2/wikis/rocketleague/brkts_wiki_specific.lua @@ -9,7 +9,10 @@ local Lua = require('Module:Lua') local Table = require('Module:Table') -local WikiSpecific = Table.copy(Lua.import('Module:Brkts/WikiSpecific/Base')) +local BaseWikiSpecific = Lua.import('Module:Brkts/WikiSpecific/Base') + +---@class RocketleagueBrktsWikiSpecific: BrktsWikiSpecific +local WikiSpecific = Table.copy(BaseWikiSpecific) function WikiSpecific.getMatchGroupContainer(matchGroupType) return matchGroupType == 'matchlist' diff --git a/components/match2/wikis/trackmania/match_summary.lua b/components/match2/wikis/trackmania/match_summary.lua index 4968d861940..9146a7b74b5 100644 --- a/components/match2/wikis/trackmania/match_summary.lua +++ b/components/match2/wikis/trackmania/match_summary.lua @@ -277,7 +277,7 @@ function CustomMatchSummary._createGame(game) return row end ----@param icon string +---@param icon string? ---@param shouldDisplay boolean? ---@param additionalElement number|string|Html|nil ---@param side integer? diff --git a/components/match2/wikis/warcraft/match_legacy.lua b/components/match2/wikis/warcraft/match_legacy.lua index 2f6782db80e..add875c1751 100644 --- a/components/match2/wikis/warcraft/match_legacy.lua +++ b/components/match2/wikis/warcraft/match_legacy.lua @@ -101,7 +101,7 @@ function MatchLegacy._convertParameters(match2) local match = Table.filterByKey(match2, function(key, entry) return not String.startsWith(key, 'match2') end) ---@cast match table match.type = match.type and string.lower(match.type) or nil - match.header = DisplayHelper.expandHeader(Logic.emptyOr(bracketData.header, bracketData.inheritedheader, ''))[1] + match.header = DisplayHelper.expandHeader(Logic.emptyOr(bracketData.header, bracketData.inheritedheader) or '')[1] match.tickername = Variables.varDefault('tournament_tickername', Variables.varDefault('tournament_ticker_name')) match.staticid = match2.match2id diff --git a/components/match2/wikis/rocketleague/player_ext_custom.lua b/components/opponent/wikis/rocketleague/player_ext_custom.lua similarity index 72% rename from components/match2/wikis/rocketleague/player_ext_custom.lua rename to components/opponent/wikis/rocketleague/player_ext_custom.lua index e8bf361be9c..6eb913659cf 100644 --- a/components/match2/wikis/rocketleague/player_ext_custom.lua +++ b/components/opponent/wikis/rocketleague/player_ext_custom.lua @@ -8,13 +8,18 @@ local Logic = require('Module:Logic') local Lua = require('Module:Lua') +local Table = require('Module:Table') local PlayerExt = Lua.import('Module:Player/Ext') +---@class RocketleaguePlayerExt: PlayerExt +local PlayerExtCustom = Table.copy(PlayerExt) + --- Asks LPDB for the team a player belonged to on a page. For specific uses only. ---@param resolvedPageName string ----@date resolvedPageName string -function PlayerExt.fetchTeamHistoryEntry(resolvedPageName, date) +---@param date string|number|osdate? +---@return {joinDate: string|number|osdate?, leaveDate: string|number|osdate?, template: string}? +function PlayerExtCustom.fetchTeamHistoryEntry(resolvedPageName, date) if Logic.isEmpty(resolvedPageName) then return end @@ -37,4 +42,4 @@ function PlayerExt.fetchTeamHistoryEntry(resolvedPageName, date) end end -return PlayerExt +return PlayerExtCustom