Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard. (http://checkstyle.sourceforge.net/) Eclipse
Eclim
Update checkstyle jar
Configure Eclim
Emacs You can use the built-in flymake to run the checkstyle in the background as you edit your file. Add this to your ~/.emacs file and change the path to the jar and conf ;; Check style of Java files. (require 'flymake) (add-hook 'find-file-hook 'flymake-find-file-hook) (defun flymake-java-init () (let* ((temp-file (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) (local-file (file-relative-name temp-file (file-name-directory buffer-file-name)))) (list "java" (list "-cp" (expand-file-name "~/.emacs.d/checkstyle-5.9-SNAPSHOT-all.jar") "com.puppycrawl.tools.checkstyle.Main" "-c" (expand-file-name "~/.emacs.d/chromium-style-5.0.xml") local-file)))) (setq flymake-allowed-file-name-masks (cons '(".+\\.java$" flymake-java-init flymake-simple-cleanup flymake-get-real-file-name) flymake-allowed-file-name-masks)) (setq flymake-err-line-patterns (cons '("\\(.*\\.java\\):\\([0-9]+\\):[0-9]+: \\(.+\\)" 1 2 nil 3) flymake-err-line-patterns)) ;; Check *Message* buffer for errors. If you don't find any, you can remove this line. (setq flymake-log-level 3) Flymake will underline lines with errors and warnings. In GUI mode, Emacs will show a tooltip when you hover your mouse over the underlined lines. Setup a shortcut to go to the next error: ;; Go through flymake errors with F4. Show the tooltip with F3. (Tooltips work only in GUI mode.) (global-set-key [f4] 'flymake-goto-next-error) (global-set-key [f3] 'flymake-display-err-menu-for-current-line) You can use the built-in C-h . (Control-h period) shortcut to show the error from the current line in the minibuffer when in running Emacs in a terminal. Alternatively, you can configure Emacs to show the error in the minibuffer after a short delay of your cursor being in that line: ;; Display errors in the minibuffer after a short delay. (setq help-at-pt-display-when-idle t) (setq help-at-pt-timer-delay 0.2) (help-at-pt-set-timer) Limitations Does not support double indentation levels for line-wrap which may generate spurious warnings. |
For Developers >