Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/snippets/other.7052.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#7052) Clean up code style and add annotations in `SelectedInfo.lua`.
3 changes: 2 additions & 1 deletion engine/User/UserUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ function UserUnit:GetCreator()
end

--- Returns the current custom name, `nil` if none
---@param filler any
---@return string | nil
function UserUnit:GetCustomName()
function UserUnit:GetCustomName(filler)
end

--- Returns a table of economy data
Expand Down
29 changes: 17 additions & 12 deletions lua/keymap/selectedinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,10 @@
---@field userUnit? UserUnit
---@field workProgress number


local Prefs = import("/lua/user/prefs.lua")
local options = Prefs.GetFromCurrentProfile('options')

local selectionOverlay = {
key = 'selection',
Label = "<LOC map_options_0006>Selection",
Pref = 'range_RenderSelected',
Type = 3,
Tooltip = "overlay_selection",
}

--- Gets rollover information for the given unit.
--- This replicates `GetRolloverInfo` but for any unit.
---@param unit UserUnit
---@return RolloverInfo
function GetUnitRolloverInfo(unit, skipFocus)
local info = {}

Expand Down Expand Up @@ -83,3 +75,16 @@ function GetUnitRolloverInfo(unit, skipFocus)

return info
end

--#region Backwards compatibility
local Prefs = import("/lua/user/prefs.lua")
local options = Prefs.GetFromCurrentProfile('options')

local selectionOverlay = {
key = 'selection',
Label = "<LOC map_options_0006>Selection",
Pref = 'range_RenderSelected',
Type = 3,
Tooltip = "overlay_selection",
}
--#endregion
Comment on lines +79 to +90
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if options and selectionOverlay are used in selectedinfo.lua

echo "=== Checking usage of 'options' in selectedinfo.lua ==="
rg -n '\boptions\b' lua/keymap/selectedinfo.lua

echo ""
echo "=== Checking usage of 'selectionOverlay' in selectedinfo.lua ==="
rg -n '\bselectionOverlay\b' lua/keymap/selectedinfo.lua

Repository: FAForever/fa

Length of output: 265


Remove unused options and selectionOverlay variables.

Both variables are defined but never used in the file. The options variable on line 81 and selectionOverlay table on lines 83-89 appear only at their definition points and have no other references. Since they're local, they cannot provide backwards compatibility to external code. Remove these dead code assignments.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lua/keymap/selectedinfo.lua` around lines 79 - 90, Remove the dead local
variables by deleting the unused import/assignment and table: drop the local
Prefs = import("/lua/user/prefs.lua") and the subsequent local options =
Prefs.GetFromCurrentProfile('options') if Prefs is only used for options, and
remove the unused local selectionOverlay table (symbols: Prefs, options,
selectionOverlay); if Prefs is used elsewhere keep the import but remove only
the options assignment and the selectionOverlay block to eliminate dead code and
leftover backwards-compatibility comments.

Loading