# Is it appropriate to edit excessive line breaks from code?

Some questions (2) have quite a few extra lines which are kind of unnecessary. I guess they could be attributed to "style" but in my opinion they make to more lines and less to readable code. For example:

if ($('.invalid').length === 0) { return 'valid'; } else { return 'invalid'; }  That's 8 lines of code that could be easier read if lines were joined. Specially with if/else statements (which usually tend to be quite large already) having an entire line just for a "{" seems a bit excessive to me. That could be reduced to something like this: if ($('.invalid').length === 0) {
return 'valid';
} else {
return 'invalid';
}


My question is would this be a valid edit if found in the future?

If someone has bad use of newlines in their code, that should be pointed out in the code review. It doesn't make any sense to fix it for them. The whole point is to show them where their code could be improved, not to edit their code to fix it.

Also, I don't agree that with your example, I prefer the first one. That's how the book I learned C++ from did it, and I'm pretty much stuck there. We don't need to start a holy war there, but there is no universal agreement regarding the finer points of style, so editing other code into your style makes no sense.

• +1 That's interesting, and a great point! Personally I don't have any exposure to C++ and the book I learned JS did it like the question, which left me stuck there too :S Also that's partially why I asked. I was interested in finding out if there was some kind of consensus here. Mar 19 '13 at 16:08

Personally I find your second example more readable. in some questions the code is rather large and has all sorts of fun stuff inside of the if/then statements and in the arguments, I think that the indentation and the brackets being on their own lines make it more readable, but that might just be personal preference (or ADHD).

this question(Email Script Security) had plenty of extra newlines, even to the point that it made the code about twice as long as it needed to be, probably something with Copy/Paste into the question. I think that things like that should be cleaned up, just for the post.

all I did was remove the extra white space lines, I didn't move any brackets though. I think that would be acceptable.