Skip to end of banner
Go to start of banner

Java code formatters for IDEs

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Team members use at least 2 IDEs: Eclipse IDE and IntelliJ IDEA. These 2 IDEs have different formatting and import organizing rules. To avoid formatting related issues in the PRs the proposal is to use agreed Formatter and Organize Imports settings.

Formatter

The attached eclipse-profile.xml is based on default built-in Eclipse formatter profile with a few changes:

  1. Indentation
    • size is 2
    • tab size is 2
    • tabulation format is spaces
  2. Line length size is 132 - this allows to work with main Editor seeing entire line even with a lot of active panels (like on screenshot)

  3. The main customization is in method invocation settings (see screenshot):




    • Line wrapping policy: Wrap all elements, except first element if not necessary

    • Force split, even if line shorter than maximum line width

    • Indentation policy: Indent by one

How to use

The attached eclipse-profile.xml can be used as folling:

Organize Imports

Eclipse default settings are:

  1. Sorting order:
    • Static imports go first
    • Packages:
      • java
      • javax
      • org
      • com
  2. Number of imports needed for .*: 99
  3. Number of static imports needed for .*: 99
  • No labels