This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 269119 - Unused global variable
Summary: Unused global variable
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Petr Pisl
Depends on:
Reported: 2016-11-25 15:29 UTC by riksoft
Modified: 2016-11-25 15:29 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description riksoft 2016-11-25 15:29:04 UTC
It would be nice to have a warning on unused global variables just the way Netbeans does for local variables.

I guess it's difficult to do and probably that's why Netbeans only checks for local variables, BUT... it would be of help even a simpler check limited to the single file in which the global variable has been declared, just the way is already working with node.js

For example, could be that only if you write in the file something like
/* check globals */

all the global variables declared in this file
not used in this file
get the warning as "unused variable".

Moreover, if some of this variables are used for sure and I don't want to see the warning I could use the already working /* global my_var */ to hide the warning.

Even better, the line containing /* check globals */
could also determine the point from where the check must start.
In other words
var a
var b

 <==== before this point globals are not checked
/* check globals */   <=== below this point globals are checked till EOF
var c
var d


var a and b will be excluded from warnings while c and v will be checked.

That's more handy if there are many globals to exclude. Basically it's a sort of /* global myvar */ but faster to use.I don't have to specify var by var.

For me every solution is good as long as it gives more power in checking global variables.
You surely knows better than me what's easier/effective

PS: Another useful tool, in conjunction with the above,
could be what we already have in Netbeans for PHP files: "Find Usages".
It's something like a find function but more specialized because it searches only in PHP scope.