Open bubaflub opened 8 years ago
Good suggestion! We've run into this with our Lua code as well.
In our case, the shipped Lua code is obfuscated and the obfuscator adds some locals for its own purposes, so having a configuration option for setting the maximum to somewhat lower than the Lua default would indeed be useful.
Ok, I'll need to check how Lua counts locals and upvalues and if there are differences between various versions of Lua and LuaJIT, then this should be simple to implement. Not sure about custom thresholds for now.
@bjorn you would probably want to run luacheck a second time, on the obfuscated code, checking only syntax errors to detect this instead of guessing how many locals can obfuscator add.
@bjorn you would probably want to run luacheck a second time, on the obfuscated code, checking only syntax errors to detect this instead of guessing how many locals can obfuscator add.
Yeah, that would be nice, but the power of luacheck for me is seeing the errors directly in Sublime Text while editing the code. The obfuscated code is only created on some build machine and it does already run some custom automatic checks there.
Not that this is an error one would run into much I think. In general, once you run into it once you'll probably avoid it easily.
Similar to #63
At work we've hit code that has more than the maximum number of local variables. Automated testing caught this but I think luacheck could have caught it for us as well. I believe the default limit is 200 local variables for a scope.
And since someone could technically compile lua with a different value, I think if we are going to check for this we should have a configuration option for what the maximum number of locals threshold is.