4 ms·
I wonder how hard it would be to write a program to automatically refactor code like this into something reasonably clean. My intuition thinks it should be diff
by BlakeCam 9y ago
I wonder how hard it would be to write a program to automatically refactor code like this into something reasonably clean. My intuition thinks it should be difficult but possible... and extremely useful.
- jeremyjh 9y agoThere are linters which do a bit of this, but they only cover the lints they have rules for. I'm pretty sure no one has a rule for "all loop indices declared as class members" because no one writing code of this quality has yet used a linter. Many issues in this code-base are not tractable at all for automated repair: how are you going to rework thousands of line long methods into well-factored classes and methods?
- dbremner 9y agoReSharper (and presumably IntelliJ) supports expression-based search and replace. Here are some commits where I used it to remove boilerplate from some test cases. The code was written long before MSTest added support for Assert.ThrowsException. https://github.com/dbremner/PowerCollections/commit/a364a1548e7ba0e8e57ec63f4cd09aab04c09cda https://github.com/dbremner/PowerCollections/commit/a364a154... https://github.com/dbremner/PowerCollections/commit/1de2f916faacea4c62403edb4916363711c5a0e9 https://github.com/dbremner/PowerCollections/commit/1de2f916... https://github.com/dbremner/PowerCollections/commit/183e3c7c345c667c575a046af348dd6444a24895 https://github.com/dbremner/PowerCollections/commit/183e3c7c...