We have automated the process of commenting out the unused class methods.
- Python >= 3.6
- Vulture (python package)
To run this script you will need to have Python and Vulture installed on your machine. The instructions to setup Python can be found online. After installing Python, run the following command to install Vulture.
pip install vulture
-
Clone the repository & open the repository root directory in terminal.
-
To comment the unused the code. Run the command with the following pattern.
<python> <main.py> <class file path> <usage file path>
-
We have a class file named
class_file.py
. The usage file is namedusage_file.py
. -
In
usage_file.py
, we are calling methods from theclass_file.py
which is- displayPublicMembers()
-
In
class_file.py
, the methods which are not being used are- _displayProtectedMembers()
- accessPrivateMembers()
-
Open a terminal and run the following command to see the script in action:
python main.py class_file.py usage_file.py
-
The above mentioned unused methods are commented and we can check the code in
class_file.py
. -
The output we get after running the above mentioned command is
<--- Unused Methods ---> 1) _displayProtectedMembers 2) accessPrivateMembers