Is it possible to find all one line statements like for, if or else and add brackets to them if there is no bracket?
is there a helpfull function in eclipse or can i use any kind of regex, grep or something else? If its not possible to add the bracktes automaticily, it would be also helpful to find all places in the code where such a function is used.
I think you’d be better off using the code formatter in Eclipse for this instead of a regex. It just seems cleaner to do that.
Of cousre, it will format everything, so make sure you have every possible setting to your liking. You’ll probably find it’s more trouble than it’s worth.
If you really want your code cleaned up, just tell your programmers that going forward, to use this new standard, and if they see existing code not following the standard to fix it. Perhaps ask them to check the files once over before checking in.
Personally, I think mandates like this are silly. Sure, they can lead to inconsistent code between developers, but I think any developer is capable of reading either way (especially if they work with developers who do it the other way) and that fights like that between developers over it are quite silly. (Although if it’s a huge majority, I think the minority just needs to conform. I’m on a group of 10 programmers, and the others are gung-ho over Hungarian notation. I object to it, but that’s what the standard is, so that’s what I do. I don’t have to like it, but as a professional that’s what you do.)