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.Bridgesis a complete mess. In some places, hashrings are referred to as
BridgeHolders, in other places as
Buckets(though not to be confused with the
Bucket.pymodule, 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.Distinherit, 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 a
Distributorshould be a subclass of a the "base" hashring class is unclear and unnecessary, and we should move away from that. A
Distributoris something which distributes bridges to users, not some weird half-thought-out hashring subclass.
The various Distributors in
bridgedb.Distshould be different modules.
Almost none of the code in
Dist.pyis 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.