Skip to content

Commit 2295d1e

Browse files
authored
refactor: remove some more unused functions (#571)
1 parent a62abb0 commit 2295d1e

2 files changed

Lines changed: 0 additions & 68 deletions

File tree

lua/gitlab/utils/init.lua

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,6 @@ M.time_since = function(date_string, current_date_table)
126126
end
127127
end
128128

129-
---Removes the first value from a list and returns the new, smaller list
130-
---@param tbl table The table
131-
---@return table
132-
M.remove_first_value = function(tbl)
133-
local sliced_list = {}
134-
if M.table_size(tbl) <= 1 then
135-
return sliced_list
136-
end
137-
for i = 2, #tbl do
138-
table.insert(sliced_list, tbl[i])
139-
end
140-
141-
return sliced_list
142-
end
143-
144129
---Spreads all the values from t2 into t1
145130
---@param t1 table The first table (gets the values)
146131
---@param t2 table The second table
@@ -176,14 +161,6 @@ M.contains = function(list, search_value)
176161
return false
177162
end
178163

179-
---Trims whitespace from a string
180-
---@param s string The string to trim
181-
---@return string
182-
M.trim = function(s)
183-
local res = s:gsub("^%s+", ""):gsub("%s+$", "")
184-
return res
185-
end
186-
187164
---Splits a string by new lines and returns an iterator
188165
---@param s string The string to split
189166
---@return table: An iterator object
@@ -556,10 +533,6 @@ M.get_lines = function(start_line, end_line)
556533
return vim.api.nvim_buf_get_lines(0, start_line - 1, end_line, false)
557534
end
558535

559-
M.make_comma_separated_readable = function(str)
560-
return string.gsub(str, ",", ", ")
561-
end
562-
563536
---Select a git branch and perform callback with the branch as an argument
564537
---@param cb function The callback to perform with the selected branch
565538
M.select_target_branch = function(cb)
@@ -576,11 +549,6 @@ M.select_target_branch = function(cb)
576549
end)
577550
end
578551

579-
M.basename = function(str)
580-
local name = string.gsub(str, "(.*/)(.*)", "%2")
581-
return name
582-
end
583-
584552
M.get_web_url = function()
585553
local web_url = require("gitlab.state").INFO.web_url
586554
if web_url ~= nil then

tests/spec/util_spec.lua

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -86,42 +86,6 @@ describe("utils/init.lua", function()
8686
end)
8787
end)
8888

89-
describe("remove_first_value", function()
90-
it("Removes the first value correctly", function()
91-
local got = u.remove_first_value({ 1, 2 })
92-
local want = { 2 }
93-
assert.are.same(want, got)
94-
end)
95-
it("Handles a one-length list", function()
96-
local got = u.remove_first_value({ 1 })
97-
local want = {}
98-
assert.are.same(want, got)
99-
end)
100-
it("Handles a zero-length list", function()
101-
local got = u.remove_first_value({})
102-
local want = {}
103-
assert.are.same(want, got)
104-
end)
105-
end)
106-
107-
describe("table_size", function()
108-
it("Works for associative tables", function()
109-
local got = u.remove_first_value({ 1, 2 })
110-
local want = { 2 }
111-
assert.are.same(want, got)
112-
end)
113-
it("Handles a one-length list", function()
114-
local got = u.remove_first_value({ 1 })
115-
local want = {}
116-
assert.are.same(want, got)
117-
end)
118-
it("Handles a zero-length list", function()
119-
local got = u.remove_first_value({})
120-
local want = {}
121-
assert.are.same(want, got)
122-
end)
123-
end)
124-
12589
describe("contains", function()
12690
it("Finds a value in a list", function()
12791
local got = u.contains({ 1, 2 }, 1)

0 commit comments

Comments
 (0)