Menu

ProbableCause 0.1.x to check your gambas2 code for unused vars

Beta! (now 0.1.5)

Gambas 3 has the nice feature to show you variables that are not used, so you can keep your code clean.

Gambas 2 doesn't have this feature, so "ProbableCause" does it for you:
1. Choose your project with File, Open
2. Push project button to get all the program code files (.module and .class)
3. Scan all files (or select one/some of the files) and press the button to start scanning

You get lists on your screen that get filled with the variables you used, sorted in public, private, and local variables.

Plus a list with the procedure names. (e.g. check consequent naming?)
The local use and for public the global use is counted for each.

A report can be made with a summary and the % not used, or a detailed list with all names, the sourcecodeline-number and file, eventually procedures, internal and external count.

When used on this ProbableCause project, while working on it, I found two bugs, and could reduce the garbage:

Name   Counted Unused int. % unused int.   Unused ext. % unused ext.

Local DIM   118 27  23 %            

Parameters  63  5   8 %         

Private Vars    49  7   14 %            

Public Vars 50          24  48 %    

Priv. Proc. 2   0   0 %         

Public Proc.    152         86  57 %    

Note that the Public Proc. contain a lot of Objects, that are not traced to their implementation yet.

After adjusting a lot of needless variables, I could bring it back to:

Name   Counted Unused int. % unused int.   Unused ext. % unused ext.

Local DIM   82  2   2 %         

Parameters  57  1   2 %         

Private Vars    48  3   6 %         

Public Vars 56          27  48 %    

Priv. Proc. 2   0   0 %         

Public Proc.    155         86  55 %    

This means that I removed:
- 27 local variables (Dim)
- 4 parameters, and found a bug with 2 other that had a wrong name due to copy-paste.
- 6 private variables
- 8 public variables
- 9 public procedures

(also some were added, so numbers seem odd when compared)

The source lines went from 2283 to 2008 lines (without comment and debug lines).

Posted by wignoxqs 2015-01-15

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.