Skip to content

Commit

Permalink
Handle lints raised by Luacheck
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 28, 2024
1 parent 012b1b5 commit cf6d6ce
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 25 deletions.
4 changes: 2 additions & 2 deletions pandoc-lua-engine/test/lua/module/pandoc-list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local group = tasty.test_group

return {
group 'List as function' {
test('equivalent to List:new', function (x)
test('equivalent to List:new', function (_)
local new = List:new {'ramen'}
local list = List {'ramen'}
assert.are_same(new, list)
Expand Down Expand Up @@ -109,7 +109,7 @@ return {
end),
test('leaves original list unchanged', function ()
local primes = List:new {2, 3, 5, 7}
local squares = primes:map(function (x) return x^2 end)
local _ = primes:map(function (x) return x^2 end)
assert.are_same({2, 3, 5, 7}, primes)
end)
},
Expand Down
2 changes: 0 additions & 2 deletions pandoc-lua-engine/test/lua/module/pandoc-structure.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
local tasty = require 'tasty'
local structure = require 'pandoc.structure'
local path = require 'pandoc.path'
local system = require 'pandoc.system'

local assert = tasty.assert
local test = tasty.test_case
Expand Down
2 changes: 1 addition & 1 deletion pandoc-lua-engine/test/lua/module/pandoc-template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ return {
)
end),
test('fails on unknown format', function ()
local success, msg = pcall(function ()
local success, _ = pcall(function ()
return pandoc.utils.type(template.default 'nosuchformat')
end)
assert.is_falsy(success)
Expand Down
2 changes: 1 addition & 1 deletion pandoc-lua-engine/test/lua/module/pandoc-utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ return {

group 'to_simple_table' {
test('convertes Table', function ()
function simple_cell (blocks)
local function simple_cell (blocks)
return {
attr = pandoc.Attr(),
alignment = "AlignDefault",
Expand Down
2 changes: 1 addition & 1 deletion pandoc-lua-engine/test/lua/module/pandoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local test = tasty.test_case
local group = tasty.test_group
local assert = tasty.assert

function os_is_windows ()
local function os_is_windows ()
return package.config:sub(1,1) == '\\'
end

Expand Down
3 changes: 1 addition & 2 deletions pandoc-lua-engine/test/sample.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function Writer (doc, opts)
end

local pipe = pandoc.pipe
local stringify = (require 'pandoc.utils').stringify

-- Choose the image format based on the value of the
-- `image_format` environment variable.
Expand Down Expand Up @@ -283,7 +282,7 @@ local function html_align(align)
end
end

function CaptionedImage(src, tit, caption, attr)
function CaptionedImage(src, _, caption, attr)
if #caption == 0 then
return '<p><img src="' .. escape(src,true) .. '" id="' .. attr.id ..
'"/></p>'
Expand Down
2 changes: 1 addition & 1 deletion tools/extract-changes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function Pandoc(el)
local newblocks = {}
i = 1
local i = 1
while i <= #el.blocks and
not (el.blocks[i].t == "Header" and el.blocks[i].level == 2) do
i = i+1
Expand Down
6 changes: 3 additions & 3 deletions tools/moduledeps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ end

local transitive = {}

function prind(ind, s)
local function prind(ind, s)
io.write(string.rep(" ",ind) .. s .. "\n")
end

function add_transitive_deps(mod)
local function add_transitive_deps(mod)
if transitive[mod] then
return
end
Expand All @@ -53,7 +53,7 @@ function add_transitive_deps(mod)
end
end

function print_direct_deps(mod, ind)
local function print_direct_deps(mod, ind)
ind = ind or 0
prind(ind, mod)
for dep,_ in pairs(dependencies[mod]) do
Expand Down
21 changes: 11 additions & 10 deletions tools/update-lua-module-docs.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local ipairs, load, next, pairs, print, tostring, type, warn =
ipairs, load, next, pairs, print, tostring, type, warn
local ipairs, next, pairs, print, tostring, type, warn =
ipairs, next, pairs, print, tostring, type, warn
local string, table = string, table
local _G, arg = _G, arg

Expand All @@ -21,7 +21,7 @@ local function sorted (tbl)
end
table.sort(keys)
local i = 0
local iter = function (state, ctrl)
local iter = function (_, ctrl)
if i > 0 and ctrl == nil then
return nil
else
Expand Down Expand Up @@ -101,7 +101,7 @@ end
local function argslist (parameters)
local required = List{}
local optional = List{}
for i, param in ipairs(parameters) do
for _, param in ipairs(parameters) do
if param.optional then
optional:insert(param.name)
else
Expand Down Expand Up @@ -186,7 +186,7 @@ local function render_type (name, level, modulename)
local propattr = {'type-' .. id .. '-properties'}
properties:insert(Header(level + 1, "Properties", propattr))
for propname, prop in sorted(metatable.docs.properties) do
attr = {'type-' .. nameprefix .. '.' .. name .. '.' .. propname}
local attr = {'type-' .. nameprefix .. '.' .. name .. '.' .. propname}
properties:insert(Header(level + 2, propname, attr))
properties:insert(
Plain(read_inlines(prop.description) ..
Expand All @@ -199,6 +199,7 @@ local function render_type (name, level, modulename)
if next(metatable.methods) then
local attr = {'type-' .. id .. '-methods'}
methods:insert(Header(level + 1, "Methods", attr))
-- luacheck: ignore propname
for propname, method in sorted(metatable.methods) do
-- attr = {'type-' .. modulename .. '.' .. name .. '.' .. propname}
-- methods:insert(Header(level + 2, propname, attr))
Expand All @@ -217,15 +218,15 @@ local function render_module (doc)
local fields = Blocks{}
if #doc.fields > 0 then
fields:insert(Header(2, 'Fields', {doc.name .. '-' .. 'fields'}))
for i, fld in ipairs(doc.fields) do
for _, fld in ipairs(doc.fields) do
fields:extend(render_field(fld, 3, doc.name))
end
end

local functions = Blocks{}
if #doc.functions > 0 then
functions:insert(Header(2, 'Functions', {doc.name .. '-' .. 'functions'}))
for i, fun in ipairs(doc.functions) do
for _, fun in ipairs(doc.functions) do
functions:extend(render_function(fun, 3, doc.name))
end
end
Expand All @@ -234,7 +235,7 @@ local function render_module (doc)
local types = type(doc.types) == 'function' and doc.types() or {}
if #types > 0 then
typedocs:insert(Header(2, 'Types', {doc.name .. '-' .. 'types'}))
for i, ty in ipairs(types) do
for _, ty in ipairs(types) do
typedocs:extend(render_type(ty, 3, doc.name))
end
end
Expand Down Expand Up @@ -299,13 +300,13 @@ local function foo (input, blocks, start)
blocks:extend(render_module(documentation(object)))
return foo(input, blocks, input:find(autogen_end, mstop) or -1)
else
local reflinks_start, reflinks_stop = input:find(reflinks_marker, start)
local _, reflinks_stop = input:find(reflinks_marker, start)
blocks:insert(rawmd(input:sub(start, reflinks_stop)))
return blocks
end
end

function _G.Reader (inputs, opts)
function _G.Reader (inputs, _)
local blocks = foo(tostring(inputs), Blocks{}, 1)
blocks = blocks:walk {
Link = function (link)
Expand Down
4 changes: 2 additions & 2 deletions tools/update-readme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

local f = assert(io.open("MANUAL.txt", "r"))
local manual = f:read("*all")
mdoc = pandoc.read(manual, "markdown")
local mdoc = pandoc.read(manual, "markdown")
f:close()
result = {}
local result = {}

function Div(elem)
local ident = elem.identifier or ""
Expand Down

0 comments on commit cf6d6ce

Please sign in to comment.