From efeae0c0469ea14c93b9fcc26336839839f3670f Mon Sep 17 00:00:00 2001 From: Terje Larsen Date: Tue, 9 Oct 2018 18:22:26 +0200 Subject: [PATCH 1/2] Make bundler optional For some projects I don't have bundler as part of the Gemfile but run it as an external tool. With this kind of setup it would be nice to be able to opt out of `bundle exec` even if you have a Gemfile and are using bundler for the rest of the project. --- rubocopfmt.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rubocopfmt.el b/rubocopfmt.el index 44b767a..0d5fe2a 100644 --- a/rubocopfmt.el +++ b/rubocopfmt.el @@ -58,6 +58,11 @@ :type 'string :group 'rubocopfmt) +(defcustom rubocopfmt-use-bundler-when-possible t + "When t and Gemfile is present, run rubocop with 'bundle exec'." + :type 'boolean + :group 'rubocopfmt) + (defcustom rubocopfmt-disabled-cops '("Lint/Debugger" ; Don't remove debugger calls. "Lint/UnusedBlockArgument" ; Don't rename unused block arguments. @@ -237,7 +242,8 @@ If FILE is not found in DIRECTORY, the parent of DIRECTORY will be searched." "--auto-correct" "--format" "emacs"))) - (if (rubocopfmt--bundled-path-p src-dir) + (if (and rubocopfmt-use-bundler-when-possible + (rubocopfmt--bundled-path-p src-dir)) (setq fmt-command "bundle" fmt-args (append (list "exec" rubocopfmt-rubocop-command) fmt-args))) From 920917ddd92e396c7ec8b56ff5c675c62ccaf2e3 Mon Sep 17 00:00:00 2001 From: Terje Larsen Date: Tue, 9 Oct 2018 18:28:34 +0200 Subject: [PATCH 2/2] Update readme with bundler opt-out --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 52b5968..1b17c68 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,10 @@ for rubocopfmt to work. This ensures that formatting is done with the same version of RuboCop that the project lists as a dependency. +If you don't care about having a specific version of RuboCop and/or are using it as an +external tool, but still use a `Gemfile`, you can opt out from this behaviour by configuring +the option `(setq rubocopfmt-use-bundler-when-possible nil)`. + ## Disabled Cops There's a few of cops in RuboCop that can cause confusion and annoyance when run