diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..f12fa30 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,81 @@ +std = "lua51" +max_line_length = false +codes = true +exclude_files = { + "**/libs", +} +ignore = { + "11./SLASH_.*", -- Setting an undefined (Slash handler) global variable + "212", -- Unused argument + "213", -- Unused loop variable +} +globals = { + "BetterAddonListDB", + + "AddonCharacterDropDown", + "AddonCharacterDropDownButton", + "AddonList", + "AddonList_Enable", + "AddonList_SetSecurityIcon", + "AddonList_SetStatus", + "AddonListForceLoad", + "AddonTooltip_Update", + "C_AddOns", + "C_Timer", + "CloseDropDownMenus", + "CopyTable", + "CreateFrame", + "GameTooltip", + "GetAddOnMemoryUsage", + "GetLocale", + "hooksecurefunc", + "IsAddonVersionCheckEnabled", + "IsShiftKeyDown", + "PlaySound", + "ResetAddOns", + "SecureCmdOptionParse", + "ShowUIPanel", + "SlashCmdList", + "SOUNDKIT", + "ToggleDropDownMenu", + "UIDropDownMenu_AddButton", + "UIDropDownMenu_CreateInfo", + "UIDropDownMenu_Initialize", + "UIDROPDOWNMENU_MENU_VALUE", + "UIDropDownMenu_SetSelectedValue", + "UnitName", + "UpdateAddOnMemoryUsage", + + "tContains", + "tostringall", + "sort", + "wipe", + + "ADDON_BANNED_TOOLTIP", + "CANCEL", + "FILTER", + "LOAD_ADDON", + "NONE", + "OKAY", + "YES", +} +files["BetterAddonList.lua"].globals = { + "LibStub", + "AddonList_HasAnyChanged", + "AddonListOkayButton", + "CreateDataProvider", + "CreateIndexRangeDataProvider", + "SearchBoxTemplate_OnTextChanged", +} +files["BetterAddonList_Classic.lua"].globals = { + "AddonList_Update", + "AddonListScrollFrame", + "AddonTooltip_BuildDeps", + "FauxScrollFrame_Update", + "SearchBoxTemplate_OnTextChanged", + "StaticPopup_Show", + "StaticPopupDialogs", + "ADDON_DEPENDENCIES", + "ADDON_BUTTON_HEIGHT", + "MAX_ADDONS_DISPLAYED", +} diff --git a/BetterAddonList.lua b/BetterAddonList.lua index fa5f478..065e1c3 100644 --- a/BetterAddonList.lua +++ b/BetterAddonList.lua @@ -1,21 +1,13 @@ --- luacheck: globals BetterAddonListDB SLASH_BETTERADDONLIST1 SLASH_BETTERADDONLIST2 SLASH_BETTERADDONLIST3 SlashCmdList SLASH_RELOADUI1 SLASH_RELOADUI2 --- luacheck: globals UIDropDownMenu_Initialize UIDropDownMenu_CreateInfo UIDropDownMenu_AddButton UIDropDownMenu_SetSelectedValue UIDROPDOWNMENU_MENU_VALUE --- luacheck: globals SearchBoxTemplate_OnTextChanged IsAddonVersionCheckEnabled ResetAddOns CreateDataProvider CreateIndexRangeDataProvider --- luacheck: globals AddonList AddonCharacterDropDown AddonCharacterDropDownButton AddonListForceLoad AddonListOkayButton --- luacheck: globals AddonList_Enable AddonList_SetSecurityIcon AddonList_SetStatus AddonList_HasAnyChanged AddonTooltip_Update --- luacheck: globals SOUNDKIT --- luacheck: globals C_AddOns - local ADDON_NAME, ns = ... BetterAddonListDB = BetterAddonListDB or {} -local LibDialog = LibStub("LibDialog-1.0") +local LibDialog = LibStub("LibDialog-1.0n") local _G = _G local GetAddOnMetadata = C_AddOns.GetAddOnMetadata local L = ns.L -L.LOAD_ADDON = GetLocale() == "ruRU" and "Загрузить" or _G.LOAD_ADDON +L.LOAD_ADDON = GetLocale() == "ruRU" and "Загрузить" or LOAD_ADDON local UpdateList @@ -158,7 +150,6 @@ function addon:PLAYER_LOGIN() local regions = {AddonListForceLoad:GetRegions()} regions[1]:SetPoint("LEFT", AddonListForceLoad, "RIGHT", 2, 0) regions[1]:SetText(L["Load out of date"]) - regions = nil -- let the frame overlap over ui frames --UIPanelWindows["AddonList"].area = nil @@ -635,7 +626,7 @@ do local memory = owner.memoryUsage if memory then - local text = "" + local text if memory > 1000 then memory = memory / 1000 text = L["Memory: %.02f MB"]:format(memory) @@ -779,7 +770,7 @@ do if (searchString ~= "" and oldText ~= searchString) or next(filterList) then local list = {} for i=1, C_AddOns.GetNumAddOns() do - local name, title, notes = C_AddOns.GetAddOnInfo(i) + local name, title = C_AddOns.GetAddOnInfo(i) if (searchString == "" or (strfind(name:lower(), searchString, nil, true) or (title and strfind(title:lower(), searchString, nil, true)))) and checkFilters(i) then list[#list + 1] = i end diff --git a/BetterAddonList_Classic.lua b/BetterAddonList_Classic.lua index beb0a54..7043e19 100644 --- a/BetterAddonList_Classic.lua +++ b/BetterAddonList_Classic.lua @@ -1,14 +1,7 @@ --- luacheck: globals BetterAddonListDB SLASH_BETTERADDONLIST1 SLASH_BETTERADDONLIST2 SLASH_BETTERADDONLIST3 SlashCmdList SLASH_RELOADUI1 SLASH_RELOADUI2 --- luacheck: globals StaticPopup_Show UIDropDownMenu_Initialize UIDropDownMenu_CreateInfo UIDropDownMenu_AddButton UIDropDownMenu_SetSelectedValue UIDROPDOWNMENU_MENU_VALUE --- luacheck: globals FauxScrollFrame_Update SearchBoxTemplate_OnTextChanged IsAddonVersionCheckEnabled ResetAddOns AddonTooltip_BuildDeps --- luacheck: globals AddonList AddonCharacterDropDown AddonCharacterDropDownButton AddonListForceLoad AddonListScrollFrame AddonList_Enable --- luacheck: globals AddonList_SetSecurityIcon AddonList_SetStatus AddonList_Update AddonTooltip_Update ADDON_BUTTON_HEIGHT MAX_ADDONS_DISPLAYED SOUNDKIT - local ADDON_NAME, ns = ... BetterAddonListDB = BetterAddonListDB or {} local _G = _G -local tconcat = table.concat local AddonList_Update = AddonList_Update local ADDON_BUTTON_HEIGHT = ADDON_BUTTON_HEIGHT @@ -156,7 +149,6 @@ function addon:PLAYER_LOGIN() local regions = {AddonListForceLoad:GetRegions()} regions[1]:SetPoint("LEFT", AddonListForceLoad, "RIGHT", 2, 0) regions[1]:SetText(L["Load out of date"]) - regions = nil -- let the frame overlap over ui frames --UIPanelWindows["AddonList"].area = nil @@ -654,7 +646,7 @@ do local memory = owner.memory if memory then - local text = "" + local text if memory > 1000 then memory = memory / 1000 text = L["Memory: %.02f MB"]:format(memory) @@ -679,7 +671,7 @@ do entry:Hide() else -- aaaaand copy from AddonList_Update - local name, title, notes, loadable, reason, security = C_AddOns.GetAddOnInfo(addonIndex) + local name, title, _, loadable, reason, security = C_AddOns.GetAddOnInfo(addonIndex) local enabled = C_AddOns.GetAddOnEnableState(addonIndex, character) > 0 local checkbox = _G["AddonListEntry"..i.."Enabled"] @@ -830,7 +822,7 @@ do elseif oldText ~= searchString or next(filterList) then wipe(searchList) for i=1, C_AddOns.GetNumAddOns() do - local name, title, notes = C_AddOns.GetAddOnInfo(i) + local name, title = C_AddOns.GetAddOnInfo(i) if (searchString == "" or (strfind(name:lower(), searchString, nil, true) or (title and strfind(title:lower(), searchString, nil, true)))) and checkFilters(i) then searchList[#searchList+1] = i end