diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..6b5ed17 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +name: Lint + +on: + - push + - pull_request + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Run luacheck + uses: nebularg/actions-luacheck@v1 + with: + annotate: warning + args: --no-color diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..e219a54 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,63 @@ +std = 'lua51' + +quiet = 1 -- suppress report output for files without warnings + +-- see https://luacheck.readthedocs.io/en/stable/warnings.html#list-of-warnings +-- and https://luacheck.readthedocs.io/en/stable/cli.html#patterns +ignore = { + '212/self', -- unused argument self + '212/event', -- unused argument event + '212/unit', -- unused argument unit + '212/element', -- unused argument element + '312/event', -- unused value of argument event + '312/unit', -- unused value of argument unit + '431', -- shadowing an upvalue + '614', -- trailing whitespace in comment (we use this for docs) + '631', -- line is too long +} + +globals = { + -- FrameXML objects we mutate + 'SlashCmdList', -- FrameXML/ChatFrame.lua +} + +read_globals = { + table = {fields = {'wipe'}}, + + -- FrameXML objects + 'DEFAULT_CHAT_FRAME', -- FrameXML/ChatFrame.lua + + -- FrameXML functions + 'DisplayTableInspectorWindow', -- AddOns/Blizzard_DebugTools/Blizzard_TableInspector.lua + 'UIParentLoadAddOn', -- FrameXML/UIParent.lua + 'nop', -- FrameXML/UIParent.lua + + -- SharedXML objects + 'MinimalSliderWithSteppersMixin', -- SharedXML/Slider/MinimalSlider.lua + 'Settings', -- SharedXML/Settings/Blizzard_Settings.lua + 'SettingsPanel', -- SharedXML/Settings/Blizzard_SettingsPanel.xml + + -- SharedXML functions + 'DevTools_Dump', -- SharedXML/Dump.lua + 'GenerateClosure', -- SharedXML/FunctionUtil.lua + 'Mixin', -- SharedXML/Mixin.lua + + -- namespaces + 'C_AddOns', + 'C_CVar', + 'C_EventUtils', + 'C_Map', + 'C_UnitAuras', + + -- API + 'CombatLogGetCurrentEventInfo', + 'CreateFrame', + 'GetBuildInfo', + 'GetLocale', + 'InCombatLockdown', + 'IsAddOnLoaded', -- until wrath classic bumps API + 'UnitAuraSlots', + 'UnitGUID', + 'UnitIsOwnerOrControllerOfUnit', + 'UnitIsUnit', +} diff --git a/modules/event.lua b/modules/event.lua index 309b602..24dd48d 100644 --- a/modules/event.lua +++ b/modules/event.lua @@ -218,7 +218,7 @@ function eventMixin:IsUnitEventRegistered(event, ...) assert(IsUnitEventValid(event, unit), 'event is not valid for the given unit') if unitEventCallbacks[unit] and unitEventCallbacks[unit][event] then - for index, data in next, unitEventCallbacks[unit][event] do + for _, data in next, unitEventCallbacks[unit][event] do if data.callback == callback then return true end diff --git a/modules/settings/panel.lua b/modules/settings/panel.lua index 0edee22..9c3964a 100644 --- a/modules/settings/panel.lua +++ b/modules/settings/panel.lua @@ -111,7 +111,7 @@ function addon:RegisterSettings(savedvariable, settings) internalRegisterSettings(savedvariable, settings) else -- don't abuse OnLoad internally - addon:RegisterEvent('ADDON_LOADED', function(self, name) + addon:RegisterEvent('ADDON_LOADED', function(_, name) if name == addonName then internalRegisterSettings(savedvariable, settings) return true -- unregister diff --git a/modules/settings/savedvariables.lua b/modules/settings/savedvariables.lua index a3723c9..8438428 100644 --- a/modules/settings/savedvariables.lua +++ b/modules/settings/savedvariables.lua @@ -1,4 +1,4 @@ -local addonName, addon = ... +local _, addon = ... -- callback system that addons can use to detect when the player changes -- any setting, but also used internally to update the settings panel