Skip to content

Commit

Permalink
fix: fixing stylua issues with gotos
Browse files Browse the repository at this point in the history
  • Loading branch information
wllfaria committed Aug 16, 2024
1 parent 2fa149e commit 58b5b74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
29 changes: 13 additions & 16 deletions lua/ledger/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,25 @@ function M.get_missing_commodities()

for filename, postings in pairs(context.postings) do
for _, posting in pairs(postings) do
if not posting.commodity then
goto continue
end

local commodity_name = posting.commodity.text
local has_commodity = false

for _, commodities in pairs(context.commodities) do
if vim.tbl_contains(commodities, commodity_name) then
goto continue
for _, accounts in pairs(context.commodities) do
if vim.tbl_contains(accounts, commodity_name) then
has_commodity = true
end
end

if not missing_accounts[filename] then
missing_accounts[filename] = {}
if not has_commodity then
if not missing_accounts[filename] then
missing_accounts[filename] = {}
end
table.insert(missing_accounts[filename], {
filename = filename,
text = commodity_name,
range = posting.account.range,
})
end
table.insert(missing_accounts[filename], {
filename = filename,
text = commodity_name,
range = posting.account.range,
})

::continue::
end
end

Expand Down
22 changes: 9 additions & 13 deletions lua/ledger/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ function M.is_ledger(path)
local config = require("ledger.config").get()
local has_match = false
for _, extension in pairs(config.extensions) do
if has_match then
goto continue
if not has_match then
has_match = path:match(extension) ~= nil and true or false
end
has_match = path:match(extension) ~= nil and true or false
end
::continue::
return has_match
end

Expand Down Expand Up @@ -75,16 +73,14 @@ function M.read_dir_rec(base_path)
end
for _, entry in pairs(entries) do
local full_path = vim.fs.joinpath(path, entry)
if M.should_ignore(full_path) then
goto continue
if not M.should_ignore(full_path) then
if M.is_directory(full_path) then
recurse(full_path, acc)
end
if M.is_ledger(entry) and not M.is_directory(full_path) then
acc[entry] = full_path
end
end
if M.is_directory(full_path) then
recurse(full_path, acc)
end
if M.is_ledger(entry) and not M.is_directory(full_path) then
acc[entry] = full_path
end
::continue::
end
end

Expand Down

0 comments on commit 58b5b74

Please sign in to comment.