From 81e64790e12bfc3d5bb150f51051d72bea551a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 9 Aug 2019 15:14:33 +0800 Subject: =?UTF-8?q?=E8=AF=8A=E6=96=AD=E6=94=AF=E6=8C=81=20Unnecessary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/diagnostics.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'server/src/core') diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua index 07c3379d..e3d3ee6a 100644 --- a/server/src/core/diagnostics.lua +++ b/server/src/core/diagnostics.lua @@ -4,6 +4,7 @@ local library = require 'core.library' local buildGlobal = require 'vm.global' local DiagnosticSeverity = require 'constant.DiagnosticSeverity' local DiagnosticDefaultSeverity = require 'constant.DiagnosticDefaultSeverity' +local DiagnosticTag = require 'constant.DiagnosticTag' local mt = {} mt.__index = mt @@ -791,6 +792,7 @@ return function (vm, lines, uri) session:doDiagnostics(session.searchUnusedLocals, 'unused-local', function (key) return { message = lang.script('DIAG_UNUSED_LOCAL', key), + tags = {DiagnosticTag.Unnecessary}, } end) -- 读取未定义全局变量 @@ -811,13 +813,15 @@ return function (vm, lines, uri) -- 未使用的Label session:doDiagnostics(session.searchUnusedLabel, 'unused-label', function (key) return { - message = lang.script('DIAG_UNUSED_LABEL', key) + message = lang.script('DIAG_UNUSED_LABEL', key), + tags = {DiagnosticTag.Unnecessary}, } end) -- 未使用的不定参数 session:doDiagnostics(session.searchUnusedVararg, 'unused-vararg', function () return { - message = lang.script.DIAG_UNUSED_VARARG + message = lang.script.DIAG_UNUSED_VARARG, + tags = {DiagnosticTag.Unnecessary}, } end) -- 只有空格与制表符的行,以及后置空格 @@ -843,6 +847,7 @@ return function (vm, lines, uri) session:doDiagnostics(session.searchRedundantParameters, 'redundant-parameter', function (max, passed) return { message = lang.script('DIAG_OVER_MAX_ARGS', max, passed), + tags = {DiagnosticTag.Unnecessary}, } end) -- x or 0 + 1 @@ -887,12 +892,14 @@ return function (vm, lines, uri) session:doDiagnostics(session.searchEmptyBlock, 'empty-block', function () return { message = lang.script.DIAG_EMPTY_BLOCK, + tags = {DiagnosticTag.Unnecessary}, } end) -- 多余的赋值 session:doDiagnostics(session.searchRedundantValue, 'redundant-value', function (max, passed) return { message = lang.script('DIAG_OVER_MAX_VALUES', max, passed), + tags = {DiagnosticTag.Unnecessary}, } end) -- Emmy相关的检查 -- cgit v1.2.3