RE: Batch code editing (was: [GD-General] C++ analyzers?)
Brought to you by:
vexxed72
From: Brian H. <bri...@py...> - 2002-07-18 21:09:39
|
But does it do context and type sensitive changes? Will it only change m_uFlags to m_uEntityFlags in only those instances where's it referenced as an entity? Most search and replace tools, no matter how elaborate, aren't designed to actually understand the actual code itself. That's my beef with doing things manually. If you change the name of a variable you can easily find the problems by compiling and fixing errors, but that's tedious and error prone. Also, silent errors can get introduced with search and replace that's done incorrectly or that doesn't handle all cases: int foo; int bar; int foobar; int blahbar; s&r foo -> blah suddenly all your foo are blah, which is what you want, but now your foobar are blahbar, which is NOT what you wanted. It's this kind of tedium and risk that often prevents programmers from willingly making sweeping changes that need to be done. When there's a global variable called "gameState" and it can/should be put into an appropriate object, but it would require changing a zillion instances of code and possibly conflicting with member variables called "gameState" so that automatic tools don't do the right thing, then often programmers just say "leave well enough alone". And you have bad code just sitting there. But, more specifically, it's something that a computer should be able to do. In fact, it's something that computers were DESIGNED to do -- automate tedious and repetitive tasks. It baffles me why I can't say "Rename CFoo::update() to CFoo::fooUpdate()", which avoids the whole s&r problem with collisions between identically or similarly named identifiers. The above is an active operation, however, and I would just be joyous with passive operations that, as I mentioned in my original e-mail, show me obvious dumb things that should be fixed, like classes defined and never used; members defined but never used; etc. You'd get lots of warnings, but they'd be easy enough to fix or ignore (e.g. padding members in structures "short dummy" or "char pad[4]", etc.) Maybe I'm being na=EFve, but this seems like the kind of thing that = would be trivially easy to implement (compared to writing a compiler + IDE), yet all we keep getting are the basic things like automatic expansion of member variables when you type "foo->". Hell, and that doesn't work 95% of the time anymore in MSVC =3D| And yes, maybe PC-Lint is the way to fix it, but damn, it sure does look...crusty. Brian |