From 9d0aef2f82ee6da4e6136d6fa1f3b727b26a5d8f Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 May 2018 13:06:05 +0100 Subject: [PATCH 1/8] Refactor rubocopfmt.el to use rubocop directly Having the rubocopfmt Ruby gem as an external dependency is becoming tedious. So lets parse rubocop's output and perform the diffing ourselves within Emacs. This effectively marks the end of the rubocopfmt Ruby gem, as I no longer need it, and will not maintain it moving forward. --- rubocopfmt.el | 130 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 111 insertions(+), 19 deletions(-) diff --git a/rubocopfmt.el b/rubocopfmt.el index 37ac1f2..ab841c8 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -37,39 +37,131 @@ ;;; Code: (defgroup rubocopfmt nil - "Minor mode for formatting Ruby buffers with rubocopfmt." + "Minor mode for formatting Ruby buffers with rubocop." + :group 'languages :link '(url-link "https://github.com/jimeh/rubocopfmt.el")) -(defcustom rubocopfmt-command "rubocopfmt" - "The 'rubocopfmt' command." +(defcustom rubocopfmt-rubocop-command "rubocop" + "Name of rubocop executable." :type 'string :group 'rubocopfmt) +(defcustom rubocopfmt-disabled-cops + '("Lint/Debugger" ; Don't remove debugger calls. + "Lint/UnusedBlockArgument" ; Don't rename unused block arguments. + "Lint/UnusedMethodArgument" ; Don't rename unused method arguments. + "Style/EmptyMethod" ; Don't remove blank line in empty methods. + ) + "A list of RuboCop Cops to disable during auto-correction. +These cops are disabled because they cause confusion during +interactive use within a text-editor." + :type '(repeat string) + :group 'rubocopfmt) + +(defcustom rubocopfmt-show-errors t + "Display errors in echo area." + :type 'boolean + :group 'rubocopfmt) + +;;;###autoload (defun rubocopfmt () - "Format the current buffer with rubocopfmt." + "Format the current buffer with rubocop." (interactive) - (let ((patchbuf (get-buffer-create "*Rubocopfmt patch*")) - (coding-system-for-read 'utf-8) - (coding-system-for-write 'utf-8) - (rubocopfmt-args - (list "--diff-format" "rcs" - "--interactive" - "--src-file" (file-truename buffer-file-name)))) + (let* ((coding-system-for-read 'utf-8) + (coding-system-for-write 'utf-8) + (tmpfile (make-temp-file "rubocopfmt" nil ".rb")) + (resultbuf (get-buffer-create "*Rubocopfmt result*")) + (patchbuf (get-buffer-create "*Rubocopfmt patch*")) + (buffer-file (file-truename buffer-file-name)) + (src-dir (file-name-directory buffer-file)) + (src-file (file-name-nondirectory buffer-file)) + (fmt-command rubocopfmt-rubocop-command) + (fmt-args (list "--stdin" src-file + "--auto-correct" + "--format" "emacs"))) + + (if (rubocopfmt--bundled-path-p src-dir) + (setq fmt-command "bundle" + fmt-args (append (list "exec" rubocopfmt-rubocop-command) + fmt-args))) + + (if rubocopfmt-disabled-cops + (setq fmt-args (append fmt-args (list "--except" + (combine-and-quote-strings + rubocopfmt-disabled-cops ","))))) (unwind-protect (save-restriction (widen) + (write-region nil nil tmpfile) + (with-current-buffer resultbuf (erase-buffer)) (with-current-buffer patchbuf (erase-buffer)) - (message "Calling rubocopfmt: %s %s" - rubocopfmt-command rubocopfmt-args) - (apply #'call-process-region (point-min) (point-max) - rubocopfmt-command nil patchbuf nil rubocopfmt-args) + + (let ((current-directory src-dir)) + (message "Calling rubocop from directory \"%s\": %s %s" + src-dir fmt-command (mapconcat 'identity fmt-args " ")) + (apply #'call-process-region (point-min) (point-max) + fmt-command nil resultbuf nil fmt-args) + (if (rubocopfmt--parse-result resultbuf tmpfile) + (call-process-region (point-min) (point-max) "diff" + nil patchbuf nil "-n" "-" tmpfile))) + (if (= (buffer-size patchbuf) 0) (message "Buffer is already rubocopfmted") - (progn - (rubocopfmt--apply-rcs-patch patchbuf) - (message "Applied rubocopfmt"))))) - (kill-buffer patchbuf))) + (rubocopfmt--apply-rcs-patch patchbuf) + (message "Applied rubocopfmt"))) + + (delete-file tmpfile) + (kill-buffer resultbuf) + (kill-buffer patchbuf)))) + +(defun rubocopfmt--parse-result (resultbuf tmpfile) + "Parse Rubocop result in RESULTBUF and write corrections to TMPFILE." + (let ((split 0)) + (with-current-buffer resultbuf + (goto-char (point-min)) + ;; Only find the separator when RuboCop has printed complaints. + (setq split (search-forward "\n====================\n" nil t)) + + ;; If no RuboCop complaints were printed, we need to find the separator at + ;; the beginning of the buffer. This separation helps prevent false + ;; positive separator matches. + (unless split + (setq split (search-forward "====================\n" nil t))) + + (if split + (when (> split 22) + (goto-char (point-min)) + (when (search-forward "[Corrected]" split t) + (write-region split (point-max) tmpfile) + t)) + (rubocopfmt--display-error resultbuf) + nil)))) + +(defun rubocopfmt--display-error (resultbuf) + "Display contents of RESULTBUF if rubocop-show-errors is t." + (if rubocopfmt-show-errors + (with-current-buffer resultbuf + (message (buffer-string))))) + +(defun rubocopfmt--bundled-path-p (directory) + "Check if there is a Gemfile in DIRECTORY, or any parent directory." + (rubocopfmt--file-search-upward directory "Gemfile")) + +(defun rubocopfmt--file-search-upward (directory file) + "Search DIRECTORY for FILE and return its full path if found, or NIL if not. + +If FILE is not found in DIRECTORY, the parent of DIRECTORY will be searched." + (let ((parent-dir (file-truename (concat (file-name-directory directory) "../"))) + (current-path (if (not (string= (substring directory (- (length directory) 1)) "/")) + (concat directory "/" file) + (concat directory file)))) + + (if (file-exists-p current-path) + current-path + (when (and (not (string= (file-truename directory) parent-dir)) + (< (length parent-dir) (length (file-truename directory)))) + (rubocopfmt--file-search-upward parent-dir file))))) (defun rubocopfmt--apply-rcs-patch (patch-buffer) "Apply an RCS-formatted diff from PATCH-BUFFER to the current buffer." From e730418ea9020ed2b5c133866046f6a9a9776403 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 May 2018 13:10:15 +0100 Subject: [PATCH 2/8] Fix complaints by package-lint and checkdoc --- rubocopfmt.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rubocopfmt.el b/rubocopfmt.el index ab841c8..1cd9eeb 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2017 Jim Myhrberg ;; Author: Jim Myhrberg -;; Keywords: ruby rubocop rubocopfmt +;; Keywords: convenience wp edit ruby rubocop ;; URL: https://github.com/jimeh/rubocopfmt-emacs ;; Version: 0.1.0 @@ -182,7 +182,7 @@ If FILE is not found in DIRECTORY, the parent of DIRECTORY will be searched." (goto-char (point-min)) (while (not (eobp)) (unless (looking-at "^\\([ad]\\)\\([0-9]+\\) \\([0-9]+\\)") - (error "invalid rcs patch or internal error in rubocopfmt--apply-rcs-patch")) + (error "Invalid rcs patch or internal error in rubocopfmt--apply-rcs-patch")) (forward-line) (let ((action (match-string 1)) (from (string-to-number (match-string 2))) @@ -203,7 +203,7 @@ If FILE is not found in DIRECTORY, the parent of DIRECTORY will be searched." (cl-incf line-offset len) (rubocopfmt--delete-whole-line len))) (t - (error "invalid rcs patch or internal error in rubocopfmt--apply-rcs-patch"))))))))) + (error "Invalid rcs patch or internal error in rubocopfmt--apply-rcs-patch"))))))))) (defun rubocopfmt--delete-whole-line (&optional arg) "Delete the current line without putting it in the `kill-ring'. @@ -232,6 +232,7 @@ function." (progn (forward-visible-line arg) (point)))))) (defun rubocopfmt--goto-line (line) + "Move cursor to LINE." (goto-char (point-min)) (forward-line (1- line))) From b8e81a35187163a29492196406e580e14a5436cb Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 May 2018 13:12:43 +0100 Subject: [PATCH 3/8] Fix repository URL --- rubocopfmt.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rubocopfmt.el b/rubocopfmt.el index 1cd9eeb..1b877ed 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -4,7 +4,7 @@ ;; Author: Jim Myhrberg ;; Keywords: convenience wp edit ruby rubocop -;; URL: https://github.com/jimeh/rubocopfmt-emacs +;; URL: https://github.com/jimeh/rubocopfmt.el ;; Version: 0.1.0 ;; This file is not part of GNU Emacs. From 69d8dd97c7ae01f924d57fcb61303b1cc99cb22b Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 May 2018 13:23:55 +0100 Subject: [PATCH 4/8] Fix typo a some whitespace --- rubocopfmt.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rubocopfmt.el b/rubocopfmt.el index 1b877ed..ae43343 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -47,12 +47,12 @@ :group 'rubocopfmt) (defcustom rubocopfmt-disabled-cops - '("Lint/Debugger" ; Don't remove debugger calls. - "Lint/UnusedBlockArgument" ; Don't rename unused block arguments. - "Lint/UnusedMethodArgument" ; Don't rename unused method arguments. - "Style/EmptyMethod" ; Don't remove blank line in empty methods. + '("Lint/Debugger" ; Don't remove debugger calls. + "Lint/UnusedBlockArgument" ; Don't rename unused block arguments. + "Lint/UnusedMethodArgument" ; Don't rename unused method arguments. + "Style/EmptyMethod" ; Don't remove blank line in empty methods. ) - "A list of RuboCop Cops to disable during auto-correction. + "A list of RuboCop cops to disable during auto-correction. These cops are disabled because they cause confusion during interactive use within a text-editor." :type '(repeat string) From 40de4b843f0254f6d59aad8234eb9f7e158de22b Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 May 2018 13:24:15 +0100 Subject: [PATCH 5/8] Fix headline description --- rubocopfmt.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rubocopfmt.el b/rubocopfmt.el index ae43343..5bf4a48 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -1,4 +1,4 @@ -;;; rubocopfmt.el --- Format ruby code with rubocopfmt. +;;; rubocopfmt.el --- Format ruby code with rubocop ;; Copyright (C) 2017 Jim Myhrberg From 0eb95d9db92174b331e1d89e1703cd06a397fac1 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 May 2018 13:24:40 +0100 Subject: [PATCH 6/8] Change license and copyright to the same as go-mode.el Large portions of rubocopfmt.el is based on code from go-mode.el. As such rubocopfmt.el should really carry the same license and copyright as go-mode.el does. --- LICENSE | 28 ++++++++++++++++++++++++++++ README.md | 21 --------------------- rubocopfmt.el | 51 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..de35ac1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2014 The go-mode Authors. All rights reserved. +Portions Copyright (c) 2018 Jim Myhrberg. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 1fb7a3a..e1783eb 100644 --- a/README.md +++ b/README.md @@ -35,27 +35,6 @@ To enable formatting `ruby-mode` buffers with rubocopfmt on save, simply enable - `rubocopfmt` - Format current buffer with rubocopfmt. - `rubocopfmt-mode` - Toggle formatting on save on/off. -## License - -Copyright (C) 2017 Jim Myhrberg - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - [rubocopfmt]: https://github.com/jimeh/rubocopfmt [go-mode]: https://github.com/dominikh/go-mode.el diff --git a/rubocopfmt.el b/rubocopfmt.el index 5bf4a48..a900ade 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -1,38 +1,47 @@ ;;; rubocopfmt.el --- Format ruby code with rubocop -;; Copyright (C) 2017 Jim Myhrberg - -;; Author: Jim Myhrberg +;; Version: 0.1.0 ;; Keywords: convenience wp edit ruby rubocop ;; URL: https://github.com/jimeh/rubocopfmt.el -;; Version: 0.1.0 +;; Author: Jim Myhrberg ;; This file is not part of GNU Emacs. ;;; License: ;; -;; Permission is hereby granted, free of charge, to any person obtaining a -;; copy of this software and associated documentation files (the "Software"), -;; to deal in the Software without restriction, including without limitation -;; the rights to use, copy, modify, merge, publish, distribute, sublicense, -;; and/or sell copies of the Software, and to permit persons to whom the -;; Software is furnished to do so, subject to the following conditions: +;; Copyright (c) 2014 The go-mode Authors. All rights reserved. +;; Portions Copyright (c) 2018 Jim Myhrberg. ;; -;; The above copyright notice and this permission notice shall be included in -;; all copies or substantial portions of the Software. +;; Redistribution and use in source and binary forms, with or without +;; modification, are permitted provided that the following conditions are +;; met: ;; -;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -;; DEALINGS IN THE SOFTWARE. +;; * Redistributions of source code must retain the above copyright +;; notice, this list of conditions and the following disclaimer. +;; * Redistributions in binary form must reproduce the above +;; copyright notice, this list of conditions and the following disclaimer +;; in the documentation and/or other materials provided with the +;; distribution. +;; * Neither the name of the copyright holder nor the names of its +;; contributors may be used to endorse or promote products derived from +;; this software without specific prior written permission. +;; +;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; Commentary: ;; -;; The core parts of rubocopfmt.el are borrowed from the gofmt related parts of -;; go-mode.el 1.4.0. So most credit goes to The Go Authors. +;; This library formats Ruby code by using rubocop and it's --auto-correct +;; option. ;;; Code: From ee7b69f73bb787b030d9565d538bd0954ea8d9a2 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 May 2018 13:48:43 +0100 Subject: [PATCH 7/8] Allow showing errors in dedicated buffer --- rubocopfmt.el | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/rubocopfmt.el b/rubocopfmt.el index a900ade..33a4d9d 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -67,9 +67,18 @@ interactive use within a text-editor." :type '(repeat string) :group 'rubocopfmt) -(defcustom rubocopfmt-show-errors t - "Display errors in echo area." - :type 'boolean +(defcustom rubocopfmt-show-errors 'buffer + "Where to display rubocopfmt error output. +It can either be displayed in its own buffer, in the echo area, +or not at all. + +Please note that Emacs outputs to the echo area when writing +files and will overwrite rubocopfmt's echo output if used from +inside a `before-save-hook'." + :type '(choice + (const :tag "Own buffer" buffer) + (const :tag "Echo area" echo) + (const :tag "None" nil)) :group 'rubocopfmt) ;;;###autoload @@ -144,14 +153,22 @@ interactive use within a text-editor." (when (search-forward "[Corrected]" split t) (write-region split (point-max) tmpfile) t)) - (rubocopfmt--display-error resultbuf) + (rubocopfmt--process-errors resultbuf) nil)))) -(defun rubocopfmt--display-error (resultbuf) - "Display contents of RESULTBUF if rubocop-show-errors is t." - (if rubocopfmt-show-errors +(defun rubocopfmt--process-errors (resultbuf) + "Display contents of RESULTBUF as errors." + (if (eq rubocopfmt-show-errors 'echo) (with-current-buffer resultbuf - (message (buffer-string))))) + (message (buffer-string)))) + + (if (eq rubocopfmt-show-errors 'buffer) + (let ((errbuf (get-buffer-create "*Rubocopfmt errors*"))) + (with-current-buffer errbuf + (erase-buffer) + (goto-char (point-min)) + (insert-buffer-substring resultbuf)) + (display-buffer errbuf)))) (defun rubocopfmt--bundled-path-p (directory) "Check if there is a Gemfile in DIRECTORY, or any parent directory." From 97183947a5d0dbef7507afaea6f764b250fc5bc2 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 May 2018 14:01:19 +0100 Subject: [PATCH 8/8] Update readme for use without external rubocopfmt command --- README.md | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index e1783eb..46d6552 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,12 @@ # rubocopfmt-mode -Emacs minor-mode to format Ruby code with [rubocopfmt][] on save. - -Core parts of `rubocopfmt-mode` are borrowed from [`go-mode`][go-mode] and it's -invocation of `gofmt`. +Emacs minor-mode to format Ruby code with [RuboCop][] on save via it's +`--auto-correct` option. ## Installing -Install [rubocopfmt][]: - -``` -gem install rubocopfmt --pre -``` - -Drop `rubocopfmt.el` somewhere into you `load-path`. I favour the folder -`~/.emacs.d/vendor`: +Drop `rubocopfmt.el` somewhere into you `load-path` and require it. Personally I +favour the folder `~/.emacs.d/vendor`: ```lisp (add-to-list 'load-path "~/.emacs.d/vendor") @@ -23,8 +15,8 @@ Drop `rubocopfmt.el` somewhere into you `load-path`. I favour the folder ## Usage -To enable formatting `ruby-mode` buffers with rubocopfmt on save, simply enable -`rubocop-mode` within `ruby-mode` with something like this in your config: +To enable formatting `ruby-mode` buffers on save with rubocopfmt, simply enable +`rubocopfmt-mode` within `ruby-mode` with something like this in your config: ```lisp (add-hook 'ruby-mode-hook #'rubocopfmt-mode) @@ -32,9 +24,8 @@ To enable formatting `ruby-mode` buffers with rubocopfmt on save, simply enable ## Commands -- `rubocopfmt` - Format current buffer with rubocopfmt. +- `rubocopfmt` - Format current buffer with RuboCop. - `rubocopfmt-mode` - Toggle formatting on save on/off. - -[rubocopfmt]: https://github.com/jimeh/rubocopfmt +[rubocop]: https://github.com/bbatsov/rubocop [go-mode]: https://github.com/dominikh/go-mode.el