Refactor BridgeDB's hashrings
I have slowly been refactoring all of BridgeDB. Code which has been already refactored is named with "proper" (according to PEP8) lower-cased module names in lib/bridgedb
in the BridgeDB repository.
Some of the largest, least-unitested, (and most difficult to refactor) sections of BridgeDB's code are the Bridges.py
module and the Dist.py
module. This code primarily controls the hashrings and the distributors (which for some reason are subclasses of the very-confused hashrings structures).
The biggest problems are:
-
The code for the various types of hashrings in
bridgedb.Bridges
is a complete mess. In some places, hashrings are referred to asBridgeHolders
, in other places asBuckets
(though not to be confused with theBucket.py
module, and in other places as "hashrings". Subclassing is haphazard and confusing to say the least. In addition, the hashrings are not algorithmically as efficient as they could be. Throughout the hashring code were old-style classes, unused methods, half-implemented methods, and unnecessary parameters. All of this code needs some serious help. -
The Distributors in
bridgedb.Dist
inherit, for some unknown reason, from the improperly implemented "base class"bridgedb.Bridges.BridgeHolder
. One, this isn't how one implements a proper Python base class (by deriving from a class with__metaclass__ = abc.ABCMeta
). Two, why aDistributor
should be a subclass of a the "base" hashring class is unclear and unnecessary, and we should move away from that. ADistributor
is something which distributes bridges to users, not some weird half-thought-out hashring subclass. -
The various Distributors in
bridgedb.Dist
should be different modules. -
Almost none of the code in
Bridges.py
andDist.py
is unittested. These modules have the highest number of untested lines of code currently in BridgeDB.
After this is finished, I am mostly willing to tag BridgeDB-1.0.0
. There may be a few other refactoring that should get finished before then, but this is the main piece remaining to be completed.