selene
selene copied to clipboard
new lint: redundant pcall wrapper
Passing an anonymous function to pcall
with just a return statement calling a function can be simplified into one call to pcall
with the function directly, and whatever arguments it was sent.
local success, result = pcall(function ()
return callThisFunction(...)
end)
↓
local success, result = pcall(callThisFunction, ...)
More commonly, in Roblox development, when calling member functions of objects:
local success, result = pcall(function ()
return LocalizationService:GetCoungryRegionForPlayerAsync(player)
end)
↓
local success, result = pcall(LocalizationService.GetCountryRegionForPlayerAsync, LocalizationService, player)
I wouldn't want this to be on by default for colon-methods, I find them to be significantly harder to read, but doing it for the former and having the latter be configurable seems reasonable to me.