Quantcast

Fix globals found by mikk's find global script

Peter Eliasson [08-05-16 - 19:26]
Fix globals found by mikk's find global script
Filename
.pkgmeta
src/gui.lua
src/highscore.lua
src/inspect.lua
src/main.lua
src/migrate.lua
src/options.lua
src/parse_modules/parse_modules_core.lua
src/parse_modules/skada.lua
src/report.lua
diff --git a/.pkgmeta b/.pkgmeta
index bce074f..882e0a0 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -17,3 +17,6 @@ externals:
     vendor/LibGroupInSpecT-1.1:
         url: svn://svn.wowace.com/wow/libgroupinspect/mainline/trunk
         tag: 1.2.0
+
+tools-used:
+    - findglobals
diff --git a/src/gui.lua b/src/gui.lua
index 09d8bda..2936fed 100644
--- a/src/gui.lua
+++ b/src/gui.lua
@@ -7,9 +7,20 @@

 local addonName, addonTable = ...

--- Global functions for faster access
+-- Cached globals
 local tinsert = tinsert;
-local tContains = tContains;
+local floor = floor;
+local pairs = pairs;
+local unpack = unpack;
+local date = date;
+local ipairs = ipairs;
+local format = format;
+local wipe = wipe;
+local next = next;
+
+-- Non-cached globals (for mikk's FindGlobals script)
+-- GLOBALS: Skada, RAID_CLASS_COLORS
+

 -- Set up module
 local addon = addonTable[1];
diff --git a/src/highscore.lua b/src/highscore.lua
index 6d3e4da..ba47b28 100644
--- a/src/highscore.lua
+++ b/src/highscore.lua
@@ -10,13 +10,17 @@

 local addonName, addonTable = ...

--- Global functions for faster access
+-- Cached globals
 local tinsert = tinsert;
 local tContains = tContains;
 local tremove = tremove;
 local sort = sort;
 local random = random;
 local format = format;
+local ipairs = ipairs;
+local pairs = pairs;
+local assert = assert;
+

 -- Set up module
 local addon = addonTable[1];
diff --git a/src/inspect.lua b/src/inspect.lua
index ec8591d..c5444c5 100644
--- a/src/inspect.lua
+++ b/src/inspect.lua
@@ -20,11 +20,17 @@

 local addonName, addonTable = ...

--- Global functions for faster access
+-- Cached globals
 local floor = floor;
+local ipairs = ipairs;
+local UnitIsUnit = UnitIsUnit;
+local UnitGUID = UnitGUID;
+local GetAverageItemLevel = GetAverageItemLevel;
+local GetInventoryItemLink = GetInventoryItemLink;
+

 -- LibGroupInSpecT, lib handling inspection of group members
-local LGIST = LibStub:GetLibrary("LibGroupInSpecT-1.1")
+local LGIST = LibStub("LibGroupInSpecT-1.1")

 -- ItemUpgradeInfo, lib for information about item upgrades applied to items.
 local ItemUpgradeInfo = LibStub("LibItemUpgradeInfo-1.0")
@@ -72,7 +78,7 @@ function inspect:GetItemLevel(unitName)
 			local slotId = INVENTORY_SLOT_IDS[i];
 			local itemLink = GetInventoryItemLink(unitName, slotId);
 			if itemLink then
-				itemLevel = ItemUpgradeInfo:GetUpgradedItemLevel(itemLink)
+				local itemLevel = ItemUpgradeInfo:GetUpgradedItemLevel(itemLink)
 				if itemLevel and itemLevel > 0 then
 					numItems = numItems + 1;
 					total = total + itemLevel;
@@ -105,6 +111,7 @@ function inspect:GetInspectDataForPlayer(player)
 		player["itemLevel"] = playerInfo["itemLevel"];

 		-- Add role from spec if role is not already a valid role
+		local role = player["role"];
 		if not (role == "TANK" or role == "HEALER" or role == "DAMAGER") then
 			player["role"] = playerInfo["specRole"];
 		end
diff --git a/src/main.lua b/src/main.lua
index 4d334a2..fc85eda 100644
--- a/src/main.lua
+++ b/src/main.lua
@@ -10,8 +10,18 @@

 local addonName, addonTable = ...

+-- Cached globals
 local tinsert = tinsert;
-local tremove = tremove;
+local format = format;
+local time = time;
+local IsInGuild = IsInGuild;
+local GetGuildInfo = GetGuildInfo;
+local GetInstanceInfo = GetInstanceInfo;
+local GetRealZoneText = GetRealZoneText;
+local UnitIsUnit = UnitIsUnit;
+
+-- Non-cached globals (for mikk's FindGlobals script)
+-- GLOBALS: LibStub

 -- Create ACE3 addon
 local addon = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0")
diff --git a/src/migrate.lua b/src/migrate.lua
index c5b371b..6ffdb72 100644
--- a/src/migrate.lua
+++ b/src/migrate.lua
@@ -6,8 +6,11 @@

 local addonName, addonTable = ...

--- Global functions for faster access
+-- Cached globals
 local tinsert = tinsert;
+local pairs = pairs;
+local format = format;
+

 -- Set up module
 local addon = addonTable[1];
@@ -97,7 +100,7 @@ local function migrate10to11(db)
 	}

 	for zoneId, zoneData in pairs(highscoreDb.zones) do
-		newId = translateIds[zoneId];
+		local newId = translateIds[zoneId];
 		if newId then
 			highscoreDb.zones[newId] = zoneData
 			highscoreDb.zones[zoneId] = nil
@@ -106,7 +109,7 @@ local function migrate10to11(db)

 	for _, guildData in pairs(highscoreDb.guilds) do
 		for zoneId, zoneData in pairs(guildData.zones) do
-			newId = translateIds[zoneId];
+			local newId = translateIds[zoneId];
 			if newId then
 				guildData.zones[newId] = zoneData
 				guildData.zones[zoneId] = nil
diff --git a/src/options.lua b/src/options.lua
index 72d18f7..e10ac2f 100644
--- a/src/options.lua
+++ b/src/options.lua
@@ -7,6 +7,12 @@

 local addonName, addonTable = ...

+-- Cached globals
+local format = format;
+
+-- Non-cached globals (for mikk's FindGlobals script)
+-- GLOBALS: LibStub, InterfaceOptionsFrame_OpenToCategory
+
 -- Set up module
 local addon = addonTable[1];
 local options = addon:NewModule("options");
diff --git a/src/parse_modules/parse_modules_core.lua b/src/parse_modules/parse_modules_core.lua
index 190126f..a36f6b7 100644
--- a/src/parse_modules/parse_modules_core.lua
+++ b/src/parse_modules/parse_modules_core.lua
@@ -13,8 +13,11 @@
 local addonName, addonTable = ...
 local addon = addonTable[1];

--- Global functions for faster access
-local tinsert = tinsert;
+-- Cached globals
+local ipairs = ipairs;
+local UnitClass = UnitClass;
+local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
+

 -- Create the parseModulesCore
 local pmc = addon:NewModule("parseModulesCore")
diff --git a/src/parse_modules/skada.lua b/src/parse_modules/skada.lua
index 3c22f1d..ab31662 100644
--- a/src/parse_modules/skada.lua
+++ b/src/parse_modules/skada.lua
@@ -8,6 +8,12 @@ if not mod then return end;
 -- Global functions
 local wipe = wipe;
 local tinsert = tinsert;
+local ipairs = ipairs;
+local next = next;
+local IsAddOnLoaded = IsAddOnLoaded;
+
+-- Non-cached globals (for mikk's FindGlobals script)
+-- GLOBALS: Skada


 function mod:IsActivatable()
diff --git a/src/report.lua b/src/report.lua
index a8f103b..5c49c23 100644
--- a/src/report.lua
+++ b/src/report.lua
@@ -11,6 +11,16 @@ local addonName, addonTable = ...
 -- Global functions for faster access
 local format = format;
 local tinsert = tinsert;
+local date = date;
+local pairs = pairs;
+local ipairs = ipairs;
+local min = min;
+local strupper = strupper;
+local SendChatMessage = SendChatMessage;
+local IsInGroup = IsInGroup;
+local IsInRaid = IsInRaid;
+local IsInGuild = IsInGuild;
+

 -- Set up module
 local addon = addonTable[1];
@@ -86,7 +96,7 @@ local function createFilterString(filters)
 		if filterKey == "name" then
 			filterString = filterString .. format("Name: %s", filterValue);
 		elseif filterKey == "startTime" then
-			filterString = filterString .. format("Time: %s", date(FILTER_TIME_FORMAT, filterValue));
+			filterString = filterString .. format("Time: %s", date(FILTER_START_TIME_FORMAT, filterValue));
 		else
 			filterString = filterString .. format("%s: %s", filterKey, filterValue);
 		end
@@ -112,7 +122,7 @@ end
 -- and filterString included.
 function report:SendData(channelId, whisperToName, dataTitle, filterString, parses, numParses)
 	numParses = min(numParses, MAX_PARSES_TO_SEND);
-	channelId = string.upper(channelId);
+	channelId = strupper(channelId);

 	local lines = {"-- Guild Skada High Score --", dataTitle};