First, download the style configuration.
curl https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml -o ~/Downloads/intellij-java-google-style.xml
Install it in IntelliJ:
- Go to
Preferences > Editor > Code Style
- Press the little cog:
Import Scheme > IntelliJ IDEA code style XML
- Select the file we just downloaded
- Select
GoogleStyle
in the dropdown - Change default
Hard wrap at
inWrapping and Braces
tab to 150. - We prefer
import foo.bar.ClassName
overimport foo.bar.*
. Even in cases where we import multiple classes from the same package. This can be set by going toPreferences > Code Style > Java > Imports
and changingClass count to use import with '*'
to 9999 and `Names count to use static import with '*' to 9999. - We add the
final
keyword wherever possible. It's a drag to have to do it manually, however, so we set up the IDE to do it for us. You can either set this as the default for your IDE or you can set it just for the Airbyte project(s) that you are using.- Turn on the inspection. Go into IntelliJ Preferences...
- Editor > Inspections > Search (with the quotation marks included) "Field may be 'final'" > check the box
- Editor > Inspections > Search "local variable or parameter may be final" > check the box
- Apply the changes.
- Turn on the auto add final. Go into IntelliJ Preferences...
- Plugins - install Save Actions if not already installed.
- Go to Save Actions in the preferences left nav (NOT Tools > Actions on Save -- that is a different tool)
- Activate save actions on save > check the box
- Active save actions on shortcut > check the box
- Activate save actions on batch > check the box
- Add final modifier to field > check the box
- Add final modifier to local variable or parameter > check the box
- Apply the changes.
- Turn on the inspection. Go into IntelliJ Preferences...
- You're done!