checkStyle及code-formatter設定檔(請參考google雲端硬碟:checkStyle.7z),解壓縮後放到對應的workspace folder下。
- ※首先匯入checkStyle.xml:
- 至Menu選單Window下Preference。進入後尋找checkStyle,新增一個Global Check Configurations
- Type選擇 Internal Configuration,並命任一名稱。匯入完成後,在Global Check Configurations 清單內選取匯入的checkStyle名稱後,按下左方Set as Default 將checkStyle的檢核規則指向此設定檔即可。
- ※接著是將Code-formtter.xml 匯入:
- 一樣進入Preference。進入後尋找Java → Code Style → Fomatter
- Import Code-formatter.xml,將Active profile下拉至選取自Tax (視你 Code-Formatter 內"<profile kind="CodeFormatterProfile" name="Tax" version="11">" name 屬性的名稱為何而定)。

※當完成程式碼時,在Editor該程式碼的畫面內點滑鼠右鍵帶出Command選單,找到CheckStyle → Check Code with CheckStyle,CheckStyle會迅速從你的xml比對出不符合規則的程式碼行號,請依照checkStyle所建立的規則調整。若經CheckStyle後有大量的錯誤,可先透過Command選單尋找Source (快捷鍵:Alt + shift + S ) → Clean Up 選取自己的專案名稱,按下Next 或 Finish 將部分較易被處理的checkStyle error 自動幫你處理掉。請養成coding完畢的習慣,編寫完畢後,請在Command選單尋找Source (快捷鍵:Alt + shift + S ) → Formatter (快捷鍵:Ctrl + shift + F ) 將你的程式碼按Code-formatter排版。


沒有留言:
張貼留言