[JAVA] Automatically modify and save coding conventions in Eclipse

Overview

--A memorandum of how to automatically apply and save coding standards when developing in Eclipse

background

--It seems foolish to point out coding convention violations when reviewing source code —— Source code review time wants to focus resources on something else ――Since programming habits are ten people and ten colors, even if you are careful, you will violate coding rules

solution

--I'll have it corrected when saving automatically in Eclipse (now!) --Google has published a coding convention. For example, in Java like this --Eclipse has a format function (shortcut key: Ctrl + Shift + F), which can be modified according to the specified coding standard (imported in xml format).

Environmental setting

procedure

  1. Window-> Perspective-> Open Perspective-> Other-> Git
  2. Duplicate Git repository → Duplicate URI → URI: Enter "https://github.com/google/styleguide.git" → Next → Next → "Local destination": Enter any destination for the directory → Done
  3. Click Window-> Settings-> Java-> Code Style-> Import with Formatter and select "eclipse-java-google-style.xml" from the directory cloned in 2.-> "Apply and Close"
  4. Window-> Settings-> Java-> Editor-> Save Action-> Check "Perform Selected Action on Save"-> Check "Format Source Code"-> "Apply and Close"
  5. Right-click the project (if you already have the source code) → Source → Format to format all files
  6. After that, the format function works every time you save the source code.

Recommended Posts

Automatically modify and save coding conventions in Eclipse
How to implement coding conventions in Java
Capture and save from selenium installation in Java
How to automatically generate a constructor in Eclipse
MVC in Eclipse.
Java coding conventions