# Is editing code whitespace allowed? [duplicate]

EDIT: An edit dispute answered by rolfl is related, but dates back to 2015 and was answered by one moderator. I feel like there should be an official verdict.

This applies to edits/questions in general, but the question came to me after reviewing edits.

Lets say a user wants a review on this code:

Initial Code

public class MyProgram{
public static void main(String[] args){
int myNumber=10;
int mySecondNumber=20;
int myNewNumber=myNumber+mySecondNumber;
System.out.println( myNewNumber );
}
}


Now understandably, to help reviewers, we can edit the question with indents to make the code more readable:

First Edit

public class MyProgram{
public static void main(String[] args){
int myNumber=10;
int mySecondNumber=20;
int myNewNumber=myNumber+mySecondNumber;
System.out.println( myNewNumber );
}
}


This seems to be a common edit for new users and hard-to-read code.

Now lets say another user comes along, and applies this edit:

Second Edit

public class MyProgram {
public static void main(String[] args) {
int myNumber = 10;
int mySecondNumber = 20;
int myNewNumber = myNumber + mySecondNumber;
System.out.println(myNewNumber);
}
}


This edit spaces out all the operators and variable assignments and removes the space in the println function call.

# Q: Is an edit fixing spacing (not indentation) allowed?

Reasoning To some programmers, they use the code style of the result of the First Edit. The Initial Code indentation could have been messed up from a copy paste, so that edit seems acceptable. However, beginner programmers might not/probably don't know about the best practices to follow in order to write neat, readable code. I feel there is more value commenting on the spacing in an answer, not in an edit. This way, the answerer can provide explanation as to why to follow that practice, instead of the poster wondering why their code was edited.

• How doesn't the linked post answer this question? Is the fact that the answer is +27/-1 and accepted not verdict enough? – Peilonrayz Oct 30 '19 at 10:14
• I don't know what kind of "official verdict" you expect, considering that there seems to be no particular reason to change the standing policy that is elaborated in the answer you linked... – Vogel612 Oct 30 '19 at 10:14
• @Peilonrayz slightly tangential, but I don't think the fact that it was accepted should bear any weight. It's just the opinion of one user, which should already be reflected in the answer's score. – JAD Oct 30 '19 at 10:45
• @JAD Yes, I believe we have contrasting views. From my experience most accepts by core members show that the answer is an 'official verdict', well as close as you can get. But by and large it can mean nothing. – Peilonrayz Oct 30 '19 at 10:52
• @Peilonrayz Thing is, things get confusing when a new answer comes around on that question, surpasses it in score, and the OP isn't around anymore to change the accept button. Policies can change over time (I don't necessarily think this one will, but still), while accepts can only be changed by the op. – JAD Oct 30 '19 at 11:00
• Indentation is reviewable, we've been over this. – Mast Oct 30 '19 at 11:05
• @JAD I fail to see the point in bickering over this. Yes, your are right there are cases when an accept can mean nothing. I have stated my view, and you have yours. I don't see the need for an extended discussion on the semantics of an accept, and hypothetical situations not pertaining to this accept. – Peilonrayz Oct 30 '19 at 11:05
• @JAD Should the policy change, this can also be done in a new question overruling the older one. – Mast Oct 30 '19 at 11:11

# No, don't edit white-space

Lets take Python's recommended style guide - PEP 8.

A large part of PEP 8 dictates white space requirements. And tools like pycodestyle, pylint, pyflakes, etc all build off this to warn about incorrect white space. There are rules about how many blank lines to enter between functions, classes, methods and closures. There's rules on which side of operators should have white-space, a + b rather than a+b. There's rules on how much white-space to put before and after inline comments. I wouldn't be surprised if half the document is about white-space.

So why does this matter? Because a large part of readability comes from white-space, and we should be able to comment on that.

Lets say we enact what you're suggesting - allowing edits to white-space - then we may not be able to comment on something a large amount of people would wage wars over. This will mean that the user will continue using an 'improper' style guide and we would have failed at teaching them that white-space is actually important.

Overall it would worsen the quality of our site.

I would also think that this could cause edit wars. Some people feel passionate about what the correct way is. Some agree others disagree. This can lead to some users 'fixing' what others think are the correct way.

Whilst we could come up with rulings to stop this, do we really need more rules?

All these problems come at what benefit?

The only thing I can think of is that questions are easier to read.
However if you review a fair amount of Code Review questions you'll be able to read code following any style guide. So I don't think it's that great a benefit.