At the end of March this year (2020) I was assigned as the lead engineer on a major refactoring project. The existing coding base was several years old, and was in need of some attention.
After having read through Martin Fowler's book, Refactoring, for some much needed guidance on how best to approach this refactoring project; I began a review of the code base and from there developed a detailed strategy on each stage of the refactoring process.
It was a few weeks into this phase of the refactoring process that Michael Kennedy released a podcast, Episode #266: Refactoring your code, like magic with Sourcery. During this podcast Michael interviewed the developers of Sourcery, Brendan Maginnis and Nick Thapen. It was interesting to learn that there was potentially a tool which could automate some, if not, all of the refactoring process of my current project (🤞).
I installed the plugin into Pycharm.
On one hand I was curious to know how it would integrate, analyze and suggest refactoring changes in a large Django project code base, but on the other hand I was nervous on letting it loose and just accepting what it suggested.
My tentative approach was to test it. After a couple of hours of testing it, my confidence grew with Sourcery's suggestions. It was able to refactor overly verbose logic, into a succinct and readable structure.
I decided to try it on the code base. As expected it worked like a charm, but I still found myself double checking the suggestions. One thing which became immediately apparent was that it didn't catch the syntax which was specific to Django which needed to be refactored.
When applied to pure Python, Sourcery, is a silver bullet. Maybe in the future Sourcery could be extended to include Django and/or other frameworks (hopefully!).
I am keen to follow the development of Sourcery, especially as it moves from pattern matching to AI. The future looks positive for Sourcery, and it is a welcomed addition to my toolkit.
Thank you Sourcery.