diff --git a/init.lua b/init.lua index bca5386..b6278f4 100644 --- a/init.lua +++ b/init.lua @@ -8,6 +8,15 @@ local M = {} -- (`function M.foo`) — Lua treats them semantically identical. -- Returns: { public = ["foo","bar",...], private = ["_baz",...] } function M.parse_lua_surface(source_string) + -- Strip Lua line-comments (-- to end-of-line) before pattern matching. + -- This prevents false-positive matches inside commented-out forward-compat + -- stubs (e.g. DEPRECATED-MVP placeholders). + -- Block comments (--[[...]]) are not handled; not used in Sporel-lib code. + -- Caveat: a literal "--" inside a string would also be stripped; acceptable + -- for the lint-tool's purpose (false-negatives in pathological string cases + -- are preferable to false-positives on commented stubs). + local stripped = string.gsub(source_string, "%-%-[^\n]*", "") + local public = {} local private = {} local seen = {} @@ -23,12 +32,12 @@ function M.parse_lua_surface(source_string) end -- Form 1: M.foo = function(...) - for name in string.gmatch(source_string, "M%.([_%w]+)%s*=%s*function") do + for name in string.gmatch(stripped, "M%.([_%w]+)%s*=%s*function") do classify(name) end -- Form 2: function M.foo(...) - for name in string.gmatch(source_string, "function%s+M%.([_%w]+)") do + for name in string.gmatch(stripped, "function%s+M%.([_%w]+)") do classify(name) end