Reproduction Steps
Not happening with new projects, but I’m working on my project over 1 year and few minutes ago, Studio started to show this warning (when Idle):
GlobalUsedAsLocal: (138,2) Global ‘currentPath’ is never read before being written. Consider changing it to local
Expected Behavior
-------------------------------------------------
Actual Behavior
-------------------------------------------------
Issue Area: Studio
Issue Type: Other
Impact: Low
Frequency: Constantly
Date First Experienced: 2022-05-17 18:05:00 (-03:00)
1 Like
What this warning means is that you have a global variable that doesn’t need to be a global variable. You could make currentPath a local in that function because no other function will read the value that got written there before it gets overwritten.
Like most warnings, it doesn’t mean that your code is wrong, just that it might not be what you intended. If you don’t want to change your code to not create an unnecessary global, you can always add --!nolint GlobalUsedAsLocal
to the top of the file.
3 Likes
I didn’t touch a line in this script and, as I said, it started appearing some minutes ago.
Anyway, putting --!nolint GlobalUsedAsLocal
at the beginning of the script solved the problem.
Thank you.
Right, the linting engine got smarter. It now knows how to detect this kind of problem, where before it did not.
1 Like