From f979400edb5fa86227ee119df93e42b66d0cdbee Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 1 Oct 2020 14:54:02 +0300 Subject: [PATCH] chore: Add lint ignore overrides for warnings that get a pass Mostly because refactoring these is hard, double negatives are much harder to follow logic wise and there isn't much point in refactoring these loops unless they need other work. --- ldoc.lua | 2 ++ ldoc/builtin/global.lua | 2 ++ ldoc/builtin/table.lua | 2 ++ ldoc/doc.lua | 2 ++ ldoc/lang.lua | 2 ++ ldoc/markdown.lua | 5 ++++- ldoc/markup.lua | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ldoc.lua b/ldoc.lua index 8ba58ec..907c4fb 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -263,7 +263,9 @@ local function loadstr (ldoc,txt) load = load or utils.load chunk,err = load(txt,'config',nil,ldoc) else + -- luacheck: push ignore 113 chunk,err = loadin(ldoc,txt) + -- luacheck: pop end return chunk, err end diff --git a/ldoc/builtin/global.lua b/ldoc/builtin/global.lua index 157cce3..e927067 100644 --- a/ldoc/builtin/global.lua +++ b/ldoc/builtin/global.lua @@ -2,6 +2,8 @@ module 'global' +-- luacheck: ignore 121 + --- -- Issues an error when its argument `v` is false. -- That is, nil or false. otherwise, returns all its arguments. diff --git a/ldoc/builtin/table.lua b/ldoc/builtin/table.lua index 94852e5..b4b7d80 100644 --- a/ldoc/builtin/table.lua +++ b/ldoc/builtin/table.lua @@ -39,6 +39,8 @@ function table.pack (ยทยทยท) end -- is not given, then the '<' operator will be used. function table.sort(table , comp) end +-- luacheck: ignore 121 + --- -- Returns the elements from the given table. This function is equivalent to -- return list[i], list[i+1], ..., list[j] diff --git a/ldoc/doc.lua b/ldoc/doc.lua index e5e0606..c4908c9 100644 --- a/ldoc/doc.lua +++ b/ldoc/doc.lua @@ -230,6 +230,7 @@ function File:finish() end item:finish() -- the default is not to show local functions in the documentation. + -- luacheck: push ignore 542 if not self.args.all and (item.type=='lfunction' or (item.tags and item.tags['local'])) then -- don't add to the module -- elseif doc.project_level(item.type) then @@ -403,6 +404,7 @@ function File:finish() -- must be a free-standing function (sometimes a problem...) end end + -- luacheck: pop item.names_hierarchy = require('pl.utils').split( item.name, '[.:]' diff --git a/ldoc/lang.lua b/ldoc/lang.lua index 7dc07b9..4ef1859 100644 --- a/ldoc/lang.lua +++ b/ldoc/lang.lua @@ -93,6 +93,7 @@ function Lua:grab_block_comment(v,tok) end +-- luacheck: push ignore 312 function Lua:parse_module_call(tok,t,v) t,v = tnext(tok) if t == '(' then t,v = tnext(tok) end @@ -102,6 +103,7 @@ function Lua:parse_module_call(tok,t,v) return '...',t,v end end +-- luacheck: pop -- If a module name was not provided, then we look for an explicit module() -- call. However, we should not try too hard; if we hit a doc comment then diff --git a/ldoc/markdown.lua b/ldoc/markdown.lua index 7a6a9a1..2044bb7 100644 --- a/ldoc/markdown.lua +++ b/ldoc/markdown.lua @@ -638,12 +638,14 @@ local function blockquotes(lines) local stop = #lines for i = start+1, #lines do + -- luacheck: push ignore 542 if lines[i].type == "blank" or lines[i].type == "blockquote" then elseif lines[i].type == "normal" then if lines[i-1].type == "blank" then stop = i-1 break end else stop = i-1 break end + -- luacheck: pop end while lines[stop].type == "blank" do stop = stop - 1 end return start, stop @@ -869,7 +871,6 @@ local function code_spans(s) pos = stop + 1 end end - return s end -- Encode alt text... enodes &, and ". @@ -1166,10 +1167,12 @@ function OptionParser:run(args) while pos <= #args do local arg = args[pos] if arg == "--" then + -- luacheck: push ignore 512 for i=pos+1,#args do if self.arg then self.arg(args[i]) end return true end + -- luacheck: pop end if arg:match("^%-%-") then local info = self.long[arg:sub(3)] diff --git a/ldoc/markup.lua b/ldoc/markup.lua index 31050d0..425fb07 100644 --- a/ldoc/markup.lua +++ b/ldoc/markup.lua @@ -237,6 +237,7 @@ local formatters = discount = function(format) local ok, markdown = pcall(require, 'discount') if ok then + -- luacheck: push ignore 542 if 'function' == type(markdown) then -- lua-discount by A.S. Bradbury, https://luarocks.org/modules/luarocks/lua-discount elseif 'table' == type(markdown) and ('function' == type(markdown.compile) or 'function' == type(markdown.to_html)) then @@ -260,6 +261,7 @@ local formatters = else ok = false end + -- luacheck: pop end if not ok then print('format: using built-in markdown')