Fixing and cleaning up large if/then walls

tl;dr: It’s preference

The entire bottom half of the the code provided shows how useful the function is. All data received by the client needs to be filtered similar to this otherwise the code is highly exploitable. The function filters all data passed by a client and only allows the values 2 and 3, as an example. This is especially useful if it is inside a module script called by any script that needs to filter data received by the client, for code reusability.

I find this line to be extremely readable:
if not FilterInput(inputData) then return end

The code example was written a month ago, yet the code almost instantly reveals what it is doing. The main point behind the second function is to show abstraction. In that example, the function DoStuff does not need to know how the data is filtered, just whether it was filtered or not; this is also an example of functional programming. Sure, it can be said that two lines are not worth the abstraction, but the readability will decrease in the main function for every extra line of code needed to filter data. In other words, this method is scalable.

Yes everything has a cost, including calling a function. For completeness, here is a speed test comparison between running the original code and one without the secondary function 1000 times:

With Extra Function: 0.00005190001684240997
Without Extra Function: 0.00003460000152699649

This means the difference in time between the two, on average, is 0.0000000173 per call. If the server is suffering in performance from calling a function like this, then the problem is elsewhere. Lastly, this method is more popular than one might think. For example, these are lines 344-346 of ProfileService:

if continue_callback() ~= true then
	return
end

All that being said, it’s really just preference; I just went a little further to explain why I personally prefer to use this method. There’s really nothing wrong with using or not using guard clauses, as well as single-function architecture vs functional programming. Code it the best way that works for you and take approaches such as guard clauses as nothing more than a different way to accomplish the same task.