Skip to content

Instantly share code, notes, and snippets.

View zgy520's full-sized avatar

zgy520 zgy520

View GitHub Profile
@zgy520
zgy520 / remove-unused-imports.py
Created December 18, 2018 13:20 — forked from rodrigosetti/remove-unused-imports.py
Removes unused imports from a bunch of Java files.
#! /usr/bin/env python
# coding: utf-8
"""This script reads all .java files from a directory tree and removes unused
import statements. It may have errors in detecting import lines (e.g. import
lines within block comments, or import lines with another statement in the same
line), and it may have false-negatives when deciding to remove an import (i.e.
it only removes if the last import symbol word doesn't appear at all -
including comments - in the code).