FPtje / SublimeLinter-contrib-glualint

Linter for Garry's Mod Lua plugin for Sublime Text 3
MIT License
5 stars 2 forks source link

Error when analysing globals #5

Closed ExtReMLapin closed 5 years ago

ExtReMLapin commented 5 years ago

Hello, when trying to analyse globals (Idk what's the point exactly)

I get this error in the console

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 1088, in run_
    return self.run(edit)
  File "C:\Users\pierr\AppData\Roaming\Sublime Text 3\Installed Packages\SublimeLinter-contrib-glualint.sublime-package\projectanalysis.py", line 46, in run
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1063, in _execute_child
  File "./python3.3/subprocess.py", line 632, in list2cmdline

"Lint project" works correctly.

FPtje commented 5 years ago

The point of "analyze globals" is to get an insight into what globals you are creating and what globals you're referencing. Seeing variables like ply, i, k or v in there gives a good hint that you're forgetting the keyword local, or are using undeclared variables. Those could cause some nasty bugs that don't necessarily throw errors.

I'll look at the error later.

FPtje commented 5 years ago

The bug's been fixed.

I ran the tool on DarkRP, and besides a LOT of globals that were intended to be global, I found these in the list:

- Offset
  ...\GarrysMod\garrysmod\gamemodes\DarkRP\entities\weapons\weapon_cs_base2\shared.lua:
    line 317, column 13 - line 317, column 19
- Right
  ...\GarrysMod\garrysmod\gamemodes\DarkRP\entities\weapons\weapon_cs_base2\shared.lua:
    line 318, column 13 - line 318, column 18
- Forward
  ...\GarrysMod\garrysmod\gamemodes\DarkRP\entities\weapons\weapon_cs_base2\shared.lua:
    line 319, column 13 - line 320, column 15
- Up
  ...\GarrysMod\garrysmod\gamemodes\DarkRP\entities\weapons\weapon_cs_base2\shared.lua:
    line 319, column 13 - line 319, column 15

Those variables being global is a bug, so I fixed it. In this case it wouldn't cause problems, but imagine some caps error somewhere else using one of those var names undeclared/undefined. It'll work on your PC sometimes, but sometimes not. Sometimes it'll work for you, but not for other people. Very nasty. I vaguely remember having to deal with such bugs. Those were dreadful days.

ExtReMLapin commented 5 years ago

Thanks for the fix, interesting, in the garrysmod github repo there is around 443 globals

221 are from the TTT gamemode