On your formatting point.... Once you've decided upon a style, in some cases there may be a tool to automate compliance. For example, if you've adopted Google's Java style, there is a tool that will reformat your code:
The formatter can act on whole files, on limited lines (--lines), on specific
offsets (--offset), passing through to standard-out (default) or altered
in-place (--replace).
Note:There is no configurability as to the formatter's algorithm for
formatting. This is a deliberate design decision to unify our code formatting on
a single format.
IntelliJ, Android Studio, and other JetBrains IDEs
A
google-java-format IntelliJ plugin
is available from the plugin repository. To install it, go to your IDE's
settings and select the Plugins category. Click the Marketplace tab, search
for the google-java-format plugin, and click the Install button.
Great point! There are also other tools worth mentioning, e.g. if you use JavaScript/TypeScript there's a powerful combo of ESLint and Prettier that helps you respecting formatting rules and code style in general. Moreover, it's also able to reformat your code according to those rules, just like the tool you've mentioned.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
On your formatting point.... Once you've decided upon a style, in some cases there may be a tool to automate compliance. For example, if you've adopted Google's Java style, there is a tool that will reformat your code:
google / google-java-format
Reformats Java source code to comply with Google Java Style.
google-java-format
google-java-format
is a program that reformats Java source code to comply with Google Java Style.Using the formatter
from the command-line
Download the formatter and run it with:
The formatter can act on whole files, on limited lines (
--lines
), on specific offsets (--offset
), passing through to standard-out (default) or altered in-place (--replace
).To reformat changed lines in a specific patch, use
google-java-format-diff.py
.Note: There is no configurability as to the formatter's algorithm for formatting. This is a deliberate design decision to unify our code formatting on a single format.
IntelliJ, Android Studio, and other JetBrains IDEs
A google-java-format IntelliJ plugin is available from the plugin repository. To install it, go to your IDE's settings and select the
Plugins
category. Click theMarketplace
tab, search for thegoogle-java-format
plugin, and click theInstall
button.The plugin will…
Great point! There are also other tools worth mentioning, e.g. if you use JavaScript/TypeScript there's a powerful combo of ESLint and Prettier that helps you respecting formatting rules and code style in general. Moreover, it's also able to reformat your code according to those rules, just like the tool you've mentioned.