[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rubocop a809fa7 42/64: [Fix #24] Always run RuboCop from t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rubocop a809fa7 42/64: [Fix #24] Always run RuboCop from the project's root when within a |
Date: |
Wed, 11 Aug 2021 10:08:01 -0400 (EDT) |
branch: elpa/rubocop
commit a809fa70218155335880389ddfa4df2e1c27ca5b
Author: Bozhidar Batsov <bozhidar@batsov.com>
Commit: Bozhidar Batsov <bozhidar@batsov.com>
[Fix #24] Always run RuboCop from the project's root when within a
project
---
rubocop.el | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/rubocop.el b/rubocop.el
index 160a155..f8d2549 100644
--- a/rubocop.el
+++ b/rubocop.el
@@ -70,8 +70,10 @@
(t
file-name)))
-(defun rubocop-project-root ()
- "Retrieve the root directory of a project if available."
+(defun rubocop-project-root (&optional no-error)
+ "Retrieve the root directory of a project if available.
+
+When NO-ERROR is non-nil returns nil instead of raise an error."
(or
(car
(mapcar #'expand-file-name
@@ -79,7 +81,9 @@
(mapcar
(lambda (f) (locate-dominating-file default-directory f))
rubocop-project-root-files))))
- (error "You're not into a project")))
+ (if no-error
+ nil
+ (error "You're not into a project"))))
(defun rubocop-buffer-name (file-or-dir)
"Generate a name for the RuboCop buffer from FILE-OR-DIR."
@@ -97,10 +101,12 @@ Alternatively prompt user for directory."
(let ((directory
(or directory
(read-directory-name "Select directory: "))))
- (compilation-start
- (rubocop-build-command command (rubocop-local-file-name directory))
- 'compilation-mode
- (lambda (arg) (message arg) (rubocop-buffer-name directory)))))
+ ;; make sure we run RuboCop from a project's root if the command is
executed within a project
+ (let ((default-directory (or (rubocop-project-root 'no-error)
default-directory)))
+ (compilation-start
+ (rubocop-build-command command (rubocop-local-file-name directory))
+ 'compilation-mode
+ (lambda (arg) (message arg) (rubocop-buffer-name directory))))))
;;;###autoload
(defun rubocop-check-project ()
@@ -133,10 +139,12 @@ Alternatively prompt user for directory."
(rubocop-ensure-installed)
(let ((file-name (buffer-file-name (current-buffer))))
(if file-name
- (compilation-start
- (rubocop-build-command command (rubocop-local-file-name file-name))
- 'compilation-mode
- (lambda (_arg) (rubocop-buffer-name file-name)))
+ ;; make sure we run RuboCop from a project's root if the command is
executed within a project
+ (let ((default-directory (or (rubocop-project-root 'no-error)
default-directory)))
+ (compilation-start
+ (rubocop-build-command command (rubocop-local-file-name file-name))
+ 'compilation-mode
+ (lambda (_arg) (rubocop-buffer-name file-name))))
(error "Buffer is not visiting a file"))))
;;;###autoload
- [nongnu] elpa/rubocop 6c9c5a9 55/64: Add a bunch of commands for code formatting, (continued)
- [nongnu] elpa/rubocop 6c9c5a9 55/64: Add a bunch of commands for code formatting, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop f5fd18a 64/64: Add the ability to format on save, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop b0c5bc2 62/64: Tweak a heading, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 608a3c1 58/64: Release 0.6.0, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 0131536 39/64: Fix a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 1372ee3 60/64: Tweak some wording, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 2c884cd 25/64: Merge pull request #15 from fap-/load_tramp_dependency, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop f947fb0 30/64: Fix byte-compile warning about unused variable, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 02ad056 35/64: [Fix #17] Consider rubocop installed if bundled, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 676cabe 36/64: Expand the project root path, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop a809fa7 42/64: [Fix #24] Always run RuboCop from the project's root when within a,
ELPA Syncer <=
- [nongnu] elpa/rubocop 03bf155 52/64: Run auto-correct automatically on save (#29), ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 38d982a 56/64: Add a note about alternative packages, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop d44737a 43/64: Fix a reference to RuboCop, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 980bedb 49/64: Release 0.5, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 8e9ec29 06/64: Update for RuboCop 0.9 (fixes #1), ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop dcde702 29/64: Improve the README a bit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 0ab1329 50/64: Update the README, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 8b2c1f5 57/64: Remove mention of Prelude, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 0b4e5ce 61/64: Add an option to execute rubocop in a chroot, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 9b23b05 22/64: Make rubocop-emacs TRAMP-aware, ELPA Syncer, 2021/08/11