Reformat - raisercostin/software-wiki GitHub Wiki
Topics
Tabs vs. Spaces
Advices
- Always use spaces in original files. The formatting is kept this way. In html/javascript this might generate an increase in the filesize but don't optimize for that.
- Use the convention to always convert
tabs
to2 spaces
that will allow a lot of levels of imbrication.
End Of Lines - EOL
Conventions
Depending on the Operating System the end of line (EOL) is encoded with different characters.
- windows (CR+LF)
- linux (LF)
- old mac (CR)
Parts - Characters
Symbols
\n
might refer to\r\n
in some cases - end of line for windows\n
refers to just LF on linux
Advices
- Make a convention to use across your projects one specific type like the windows or linux convention
- Configure git with
autocrlf = false
: Intro to Git to disable automatic correction at commit/checkout time
Resources
- https://www.hanselman.com/blog/DeathToCarriageReturnsAndLinefeeds.aspx
- https://en.wikipedia.org/wiki/Newline
End Of Files - EOF
Encoding
- UTF8
- Ascii
Code Formatters
- Java
- Xml
Code Validators
- Java
- Xml
Resources
- https://eclipsesource.com/blogs/2013/07/09/invisible-chaos-mastering-white-spaces-in-eclipse/
- ant tasks: https://ant.apache.org/manual/Tasks/fixcrlf.html
- http://code.revelc.net/formatter-maven-plugin/examples.html#Custom_Configuration_File
- configure checkstyle to reject specific EOLs
- eclipse source formatting - https://www.ralfebert.de/archive/java/source_formatting/
- http://www.jillesvangurp.com/2015/01/29/enforcing-code-conventions-in-java/
- https://stackoverflow.com/questions/1955514/best-practices-for-code-formatting-on-large-projects
- eclipse checkstyle integration - http://eclipse-cs.sourceforge.net/#!/
- convert from checkstyle to eclipse formatter: Doesn't work for now. https://stackoverflow.com/questions/8327498/converting-an-eclipse-formatter-file-to-a-checkstyle-file
- checkstyle config https://stackoverflow.com/questions/34591512/configure-automatically-tab-character-for-eclipse-formatter-from-checkstyle-conf
- config of checkstyle and java formatter https://github.com/sevntu-checkstyle/sevntu.checkstyle/wiki/Java-code-Formater-and-Checkstyle-configuration-for-development
- sample sortpom - https://github.com/revelc/formatter-maven-plugin/blob/master/pom.xml
- http://www.jillesvangurp.com/2015/01/29/enforcing-code-conventions-in-java/
- eclipse code formatter for intelij https://blog.jetbrains.com/idea/2014/01/intellij-idea-13-importing-code-formatter-settings-from-eclipse/
- https://stackoverflow.com/questions/12872283/using-checkstyle-to-format-code
- http://wiki.pentaho.com/display/PEOpen/Code+Formatting+and+CheckStyle
- http://maven.apache.org/plugins/maven-checkstyle-plugin/plugin-info.html
- compatible eclipse cleanup with checkstyle - https://stackoverflow.com/questions/21211586/is-there-an-eclipse-clean-up-profile-that-matches-the-checkstyle-format-rules
- https://stackoverflow.com/questions/5003830/automatic-eol-conversion-in-eclipse
- https://github.com/google/styleguide
- sonar - http://centrumsystems.com.au/coding-standards-harmony/
- https://stackoverflow.com/questions/21211586/is-there-an-eclipse-clean-up-profile-that-matches-the-checkstyle-format-rules
- google java guide - https://google.github.io/styleguide/javaguide.html
- maven-checkstyle-plugin-2.17 depends on checkstyle-6.11.2 with default google_checks.xml https://raw.githubusercontent.com/checkstyle/checkstyle/checkstyle-6.11.2/src/main/resources/google_checks.xml