Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Tools for programmatically improving a big legacy code base?
1 point by annowiki on Feb 17, 2023 | hide | past | favorite
Hello,

I work on a 6500+ file, 1-2 million line, 30 year old code base in C++. There are many problems with it, and we've been gradually ratcheting up the use of tools to improve code quality (creating automated testing tools, pr validation pipelines, etc.; I recently went through our biggest projects and set them to level 3 treat warnings as errors; there were a lot).

But I had a thought the other day to use Python to try to const everything that could be constified in our code base. The general idea was, write some code to const all basic types at declaration, then, again, using Python, try to incrementally build the project with MSVC/MSBuild, parsing the output, deconsting anything that was fails, and hopefully end up with relatively few hard to solve errors in this fashion.

I imagine this is going to be bigger than I expect, and I already expect it to be a big job. But I've been reticent to use some of the parsing tools available (like [pygccxml][0]). I have some experience with structured text processing so I imagine this is actually doable.

However, I figure there's _got_ to be something that already exists to do simple linting tasks like this. But my Google Fu fails me.

Does anyone know of any tools for simple code improvements like const-ing everything const-able? Autoformatting tools don't make code changes as far as I know, and what I'm specifically looking for is a code-improving tool.

If not, does anyone have any experience programmatically improving a code base, especially in C++? Any tips or suggestions?

Thank you

[0]: https://github.com/CastXML/pygccxml




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: