Some people like to put the open {
bracket on a separated line, e.g:
if(...)
{
//...
}
Is editing this code by merging the first two lines into single one rude?
Is it rude? Yes. Mostly because that brace style is ugly as sin, but also because you're imposing your personal preferences on someone else's writing without good cause.
But yeah, mostly because that brace positioning style sucks.
That said, if doing so helps you trim down a code block so that it can be read without scrolling... AND you're making other substantial improvements at the same time (indentation, formatting, grammar, tags, etc.)... Then go ahead.
Rude or not it is an invitation to start a holy war.
We go to great lengths to keep brace style wars off the site. Please don't invite them on.
OTBS Rules!
It's generally accepted that you shouldn't do any more than
formatting into a markdown code block
if you're feeling generous, removing cruft like rogue tabs and making sure the code all lines up nicely (whilst honouring the OP's brace style)
where the language allows statements over multiple lines, adding a carriage return (and where required a line continuation character) here and there to reduce horizontal scroll.
removing excessive carriage returns between lines of code
Changing code style would be off-limits, as would doing things like turning (using C# as an example):
List<Thing> things = repo.GetThings()
into
var things = repo.GetThings()
Because now you're no longer working with the same code the OP is trying to debug.
See also:
When is it appropriate to edit someone else's code?
How far can I refactor the code in someone else's question? -
Don't edit just to fiddle with the braces.
However, if in the course of trying to repair severely horrible code formatting, you run the code through Lindent
or your own favorite set of indent(1)
arguments, and the braces happen to change, don't go to significant effort to put them back, either.
Generally, you'll want to leave the OP's coding style alone. Unless it makes the code overbearingly hard to read or excessively long (they do that for every single function of a rather long block of code), there's really no need to change it. The only thing you need to focus on is making sure that their indentation is correct. That extra line for the opening bracket isn't going to bother an experienced programmer who has seen it both ways many, many times.
if(...)
really is an eyesore