Skip to content

Commit cf6d6ce

Browse files
committed
Handle lints raised by Luacheck
1 parent 012b1b5 commit cf6d6ce

File tree

10 files changed

+23
-25
lines changed

10 files changed

+23
-25
lines changed

pandoc-lua-engine/test/lua/module/pandoc-list.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local group = tasty.test_group
77

88
return {
99
group 'List as function' {
10-
test('equivalent to List:new', function (x)
10+
test('equivalent to List:new', function (_)
1111
local new = List:new {'ramen'}
1212
local list = List {'ramen'}
1313
assert.are_same(new, list)
@@ -109,7 +109,7 @@ return {
109109
end),
110110
test('leaves original list unchanged', function ()
111111
local primes = List:new {2, 3, 5, 7}
112-
local squares = primes:map(function (x) return x^2 end)
112+
local _ = primes:map(function (x) return x^2 end)
113113
assert.are_same({2, 3, 5, 7}, primes)
114114
end)
115115
},

pandoc-lua-engine/test/lua/module/pandoc-structure.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
local tasty = require 'tasty'
22
local structure = require 'pandoc.structure'
3-
local path = require 'pandoc.path'
4-
local system = require 'pandoc.system'
53

64
local assert = tasty.assert
75
local test = tasty.test_case

pandoc-lua-engine/test/lua/module/pandoc-template.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ return {
2424
)
2525
end),
2626
test('fails on unknown format', function ()
27-
local success, msg = pcall(function ()
27+
local success, _ = pcall(function ()
2828
return pandoc.utils.type(template.default 'nosuchformat')
2929
end)
3030
assert.is_falsy(success)

pandoc-lua-engine/test/lua/module/pandoc-utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ return {
240240

241241
group 'to_simple_table' {
242242
test('convertes Table', function ()
243-
function simple_cell (blocks)
243+
local function simple_cell (blocks)
244244
return {
245245
attr = pandoc.Attr(),
246246
alignment = "AlignDefault",

pandoc-lua-engine/test/lua/module/pandoc.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local test = tasty.test_case
44
local group = tasty.test_group
55
local assert = tasty.assert
66

7-
function os_is_windows ()
7+
local function os_is_windows ()
88
return package.config:sub(1,1) == '\\'
99
end
1010

pandoc-lua-engine/test/sample.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function Writer (doc, opts)
2121
end
2222

2323
local pipe = pandoc.pipe
24-
local stringify = (require 'pandoc.utils').stringify
2524

2625
-- Choose the image format based on the value of the
2726
-- `image_format` environment variable.
@@ -283,7 +282,7 @@ local function html_align(align)
283282
end
284283
end
285284

286-
function CaptionedImage(src, tit, caption, attr)
285+
function CaptionedImage(src, _, caption, attr)
287286
if #caption == 0 then
288287
return '<p><img src="' .. escape(src,true) .. '" id="' .. attr.id ..
289288
'"/></p>'

tools/extract-changes.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
function Pandoc(el)
44
local newblocks = {}
5-
i = 1
5+
local i = 1
66
while i <= #el.blocks and
77
not (el.blocks[i].t == "Header" and el.blocks[i].level == 2) do
88
i = i+1

tools/moduledeps.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ end
3535

3636
local transitive = {}
3737

38-
function prind(ind, s)
38+
local function prind(ind, s)
3939
io.write(string.rep(" ",ind) .. s .. "\n")
4040
end
4141

42-
function add_transitive_deps(mod)
42+
local function add_transitive_deps(mod)
4343
if transitive[mod] then
4444
return
4545
end
@@ -53,7 +53,7 @@ function add_transitive_deps(mod)
5353
end
5454
end
5555

56-
function print_direct_deps(mod, ind)
56+
local function print_direct_deps(mod, ind)
5757
ind = ind or 0
5858
prind(ind, mod)
5959
for dep,_ in pairs(dependencies[mod]) do

tools/update-lua-module-docs.lua

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local ipairs, load, next, pairs, print, tostring, type, warn =
2-
ipairs, load, next, pairs, print, tostring, type, warn
1+
local ipairs, next, pairs, print, tostring, type, warn =
2+
ipairs, next, pairs, print, tostring, type, warn
33
local string, table = string, table
44
local _G, arg = _G, arg
55

@@ -21,7 +21,7 @@ local function sorted (tbl)
2121
end
2222
table.sort(keys)
2323
local i = 0
24-
local iter = function (state, ctrl)
24+
local iter = function (_, ctrl)
2525
if i > 0 and ctrl == nil then
2626
return nil
2727
else
@@ -101,7 +101,7 @@ end
101101
local function argslist (parameters)
102102
local required = List{}
103103
local optional = List{}
104-
for i, param in ipairs(parameters) do
104+
for _, param in ipairs(parameters) do
105105
if param.optional then
106106
optional:insert(param.name)
107107
else
@@ -186,7 +186,7 @@ local function render_type (name, level, modulename)
186186
local propattr = {'type-' .. id .. '-properties'}
187187
properties:insert(Header(level + 1, "Properties", propattr))
188188
for propname, prop in sorted(metatable.docs.properties) do
189-
attr = {'type-' .. nameprefix .. '.' .. name .. '.' .. propname}
189+
local attr = {'type-' .. nameprefix .. '.' .. name .. '.' .. propname}
190190
properties:insert(Header(level + 2, propname, attr))
191191
properties:insert(
192192
Plain(read_inlines(prop.description) ..
@@ -199,6 +199,7 @@ local function render_type (name, level, modulename)
199199
if next(metatable.methods) then
200200
local attr = {'type-' .. id .. '-methods'}
201201
methods:insert(Header(level + 1, "Methods", attr))
202+
-- luacheck: ignore propname
202203
for propname, method in sorted(metatable.methods) do
203204
-- attr = {'type-' .. modulename .. '.' .. name .. '.' .. propname}
204205
-- methods:insert(Header(level + 2, propname, attr))
@@ -217,15 +218,15 @@ local function render_module (doc)
217218
local fields = Blocks{}
218219
if #doc.fields > 0 then
219220
fields:insert(Header(2, 'Fields', {doc.name .. '-' .. 'fields'}))
220-
for i, fld in ipairs(doc.fields) do
221+
for _, fld in ipairs(doc.fields) do
221222
fields:extend(render_field(fld, 3, doc.name))
222223
end
223224
end
224225

225226
local functions = Blocks{}
226227
if #doc.functions > 0 then
227228
functions:insert(Header(2, 'Functions', {doc.name .. '-' .. 'functions'}))
228-
for i, fun in ipairs(doc.functions) do
229+
for _, fun in ipairs(doc.functions) do
229230
functions:extend(render_function(fun, 3, doc.name))
230231
end
231232
end
@@ -234,7 +235,7 @@ local function render_module (doc)
234235
local types = type(doc.types) == 'function' and doc.types() or {}
235236
if #types > 0 then
236237
typedocs:insert(Header(2, 'Types', {doc.name .. '-' .. 'types'}))
237-
for i, ty in ipairs(types) do
238+
for _, ty in ipairs(types) do
238239
typedocs:extend(render_type(ty, 3, doc.name))
239240
end
240241
end
@@ -299,13 +300,13 @@ local function foo (input, blocks, start)
299300
blocks:extend(render_module(documentation(object)))
300301
return foo(input, blocks, input:find(autogen_end, mstop) or -1)
301302
else
302-
local reflinks_start, reflinks_stop = input:find(reflinks_marker, start)
303+
local _, reflinks_stop = input:find(reflinks_marker, start)
303304
blocks:insert(rawmd(input:sub(start, reflinks_stop)))
304305
return blocks
305306
end
306307
end
307308

308-
function _G.Reader (inputs, opts)
309+
function _G.Reader (inputs, _)
309310
local blocks = foo(tostring(inputs), Blocks{}, 1)
310311
blocks = blocks:walk {
311312
Link = function (link)

tools/update-readme.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
local f = assert(io.open("MANUAL.txt", "r"))
55
local manual = f:read("*all")
6-
mdoc = pandoc.read(manual, "markdown")
6+
local mdoc = pandoc.read(manual, "markdown")
77
f:close()
8-
result = {}
8+
local result = {}
99

1010
function Div(elem)
1111
local ident = elem.identifier or ""

0 commit comments

Comments
 (0)