At Stack Overflow, many (if not most) questions are provided with some code that, for some reason or another, has an undesired behavior. For users who answer these (or at least for me), it makes a huge difference when the code is properly formatted, as opposed to crappy code that is difficult to read. I believe that providing well-formatted code improves the chances of a question getting high quality answers. Therefore, wouldn't it be a good idea to have some sort of automatic beautifying process (in the style of JS Beautifier or AStyle for C++) done to the users' code, such that:
- Overall questions' quality would be improved.
- Code-formatting edits would become unnecessary.
This process could potentially take place in the client (using JavaScript), such that server workload isn't affected at all.
EDIT: Actually, it doesn't even have to be an automatic beautification, or a button. It could just be a message that reminds the user that it's good to follow readable and consistent code style schemes when a code detects that they aren't (and maybe even stop them from posting a question when the issues are significant and the reputation is not).
EDIT 2: Here is the complete suggestion:
A preliminary test for this idea could be made using already existing code. For example, it could be employed only when the JavaScript tag or keyword are present, and could be done with the existing JS Beautify library. The code could calculate the beautified version of the user code, and then compare it to the original one, calculating the change by measuring the number of characters of difference (or Levenshtein Distance) for which working code exists here. There should be a threshold of warning where the user receives the following message:
Note: The previous image is only an example, and it definitely was not product of working code (although I claim it wouldn't be too difficult to implement a working experiment).
perltidy
before even starting to look at it - one of the downsides of SO, is the 4 space indent makes copy-pasta a little more inconvenient than normal.