Skip to content

Commit a0e6baf

Browse files
committed
refactor(path): condense if statements to single-line form for readability
1 parent c41a4b6 commit a0e6baf

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

lua/flutter-tools/utils/path.lua

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ local function parse_pubspec(pubspec_path)
124124
local content = vim.fn.readfile(pubspec_path)
125125
if not content or #content == 0 then return nil end
126126
local joined_content = table.concat(content, "\n")
127-
local ok, parsed = pcall(function()
128-
return require("flutter-tools.utils.yaml_parser").parse(joined_content)
129-
end)
127+
local ok, parsed = pcall(
128+
function() return require("flutter-tools.utils.yaml_parser").parse(joined_content) end
129+
)
130130
if ok and parsed then return parsed end
131131
return nil
132132
end
@@ -158,19 +158,15 @@ function M.find_root(patterns, startpath)
158158
if not root then return nil end
159159

160160
local pubspec_path = M.join(root, "pubspec.yaml")
161-
if not is_pub_workspace_member(pubspec_path) then
162-
return root
163-
end
161+
if not is_pub_workspace_member(pubspec_path) then return root end
164162

165163
-- Workspace member, traverse upward to find the workspace root
166164
local parent = M.dirname(root)
167165
if not parent or parent == root then return root end
168166

169167
for dir in M.iterate_parents(parent) do
170168
local workspace_pubspec = M.join(dir, "pubspec.yaml")
171-
if is_pub_workspace_root(workspace_pubspec) then
172-
return dir
173-
end
169+
if is_pub_workspace_root(workspace_pubspec) then return dir end
174170
end
175171

176172
return root

tests/path_spec.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ describe("path.find_root", function()
4444
}, standalone .. "/pubspec.yaml")
4545
end)
4646

47-
after_each(function()
48-
vim.fn.delete(test_dir, "rf")
49-
end)
47+
after_each(function() vim.fn.delete(test_dir, "rf") end)
5048

5149
local patterns = { "pubspec.yaml" }
5250

0 commit comments

Comments
 (0)