there isn't a single way to refactor code, code can be refactored in many different directions to pursue many different objectives.<p>Here's a few arbitrary ideas:<p>* Scrape_it is an arbitrary python project that shows up in google search for "pypi scrape" [1]. Looking at the code, it doesn't appear to have any automated tests. Goal: write a single unit test for the example of usage shown in the readme. The unit test should work without any dependency on : network access to remote websites or other services running locally, the current time, data files in the filesystem. Refactor by making minimal safe changes to the code as/if required in order to write a unit test.<p>* scipy's vendored copy of the useful L-BFGS-B optimisation algorithm [2] has a bunch of calls to a timer(ttime) subroutine, but the timer(ttime) subroutine was patched so it doesn't do anything. But there's still many calls to timer(ttime) throughout the lbfgsb.f code. Goal: simplify the code by identifying if any remaining variables and code related to cpu timing within lbfgsb.f can be safely removed without changing the behaviour of the algorithm. If it can be safely removed, remove it. Tricky: demonstrate with some degree of confidence that your change is safe and doesn't break behaviour!<p>* fixCache, featured on HN a few days ago [3], includes a rule to decide if a git commit is a "fix commit" based on user-supplied keyboards identified in the commit message. Goal: modify fixCache to make this functionality more flexible, so a user can still configure fixCache to use the current behaviour, but can also optionally configure fixCache to call a custom user-defined javascript function that can decide if a commit is a "fix commit" or not using all information available about the commit (e.g. which files were touched, the contents of the changes to those files, etc) instead of a list of keywords. Refactor as/if necessary to implement this feature.<p>Further reading: <a href="https://testing.googleblog.com/2008/07/how-to-write-3v1l-untestable-code.html" rel="nofollow">https://testing.googleblog.com/2008/07/how-to-write-3v1l-unt...</a> , Michael Feathers' book "working effectively with legacy code": <a href="https://ptgmedia.pearsoncmg.com/images/9780131177055/samplepages/0131177052.pdf" rel="nofollow">https://ptgmedia.pearsoncmg.com/images/9780131177055/samplep...</a><p>[1] <a href="https://pypi.org/project/scrape-it/" rel="nofollow">https://pypi.org/project/scrape-it/</a>
[2] <a href="https://github.com/scipy/scipy/tree/f865e9ed01be30c52f2b3841795aa2d8f5fa3d86/scipy/optimize/lbfgsb_src" rel="nofollow">https://github.com/scipy/scipy/tree/f865e9ed01be30c52f2b3841...</a>
[3] <a href="https://github.com/aavshr/fixCache" rel="nofollow">https://github.com/aavshr/fixCache</a>