summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/diagnostics/missing-return.lua15
-rw-r--r--script/core/diagnostics/unused-local.lua17
2 files changed, 7 insertions, 25 deletions
diff --git a/script/core/diagnostics/missing-return.lua b/script/core/diagnostics/missing-return.lua
index d90311d7..42ccaa9f 100644
--- a/script/core/diagnostics/missing-return.lua
+++ b/script/core/diagnostics/missing-return.lua
@@ -39,17 +39,6 @@ local function hasReturn(block)
end
---@param func parser.object
----@return boolean
-local function isEmptyFunction(func)
- if #func > 0 then
- return false
- end
- local startRow = guide.rowColOf(func.start)
- local finishRow = guide.rowColOf(func.finish)
- return finishRow - startRow <= 1
-end
-
----@param func parser.object
---@return integer
local function getReturnsMin(func)
local min = vm.countReturnsOfFunction(func, true)
@@ -77,10 +66,12 @@ return function (uri, callback)
return
end
+ local isMeta = vm.isMetaFile(uri)
+
---@async
guide.eachSourceType(state.ast, 'function', function (source)
-- check declare only
- if isEmptyFunction(source) then
+ if isMeta and vm.isEmptyFunction(source) then
return
end
await.delay()
diff --git a/script/core/diagnostics/unused-local.lua b/script/core/diagnostics/unused-local.lua
index 8f2ee217..52622eb2 100644
--- a/script/core/diagnostics/unused-local.lua
+++ b/script/core/diagnostics/unused-local.lua
@@ -65,24 +65,13 @@ local function isDocClass(source)
return false
end
----@param func parser.object
----@return boolean
-local function isEmptyFunction(func)
- if #func > 0 then
- return false
- end
- local startRow = guide.rowColOf(func.start)
- local finishRow = guide.rowColOf(func.finish)
- return finishRow - startRow <= 1
-end
-
---@param source parser.object
local function isDeclareFunctionParam(source)
if source.parent.type ~= 'funcargs' then
return false
end
local func = source.parent.parent
- return isEmptyFunction(func)
+ return vm.isEmptyFunction(func)
end
return function (uri, callback)
@@ -90,6 +79,8 @@ return function (uri, callback)
if not ast then
return
end
+
+ local isMeta = vm.isMetaFile(uri)
local ignorePatterns = config.get(uri, 'Lua.diagnostics.unusedLocalExclude')
local ignore = glob.glob(ignorePatterns)
guide.eachSourceType(ast.ast, 'local', function (source)
@@ -107,7 +98,7 @@ return function (uri, callback)
if isDocClass(source) then
return
end
- if isDeclareFunctionParam(source) then
+ if isMeta and isDeclareFunctionParam(source) then
return
end
local data = hasGet(source)