Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubocop config file now includes in execution #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions rubocop.el
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"The command used to run RuboCop's autocorrection."
:type 'string)

(defcustom rubocop-config-file-names
'(".rubycop.yml" ".rubycop" "rubocop.yml" ".rubocop")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rubycop? I've never seen such a config file for RuboCop. The only valid name is .rubocop.yml. I should now. :-)

"A list of valid config file names"
:type '(repeat string))

(defcustom rubocop-extensions
'()
"A list of extensions to be loaded by RuboCop."
Expand Down Expand Up @@ -90,6 +95,20 @@ When NO-ERROR is non-nil returns nil instead of raise an error."
nil
(error "You're not into a project"))))

(defun rubocop-config-file ()
"Return full path to rubocop config file if found."
(car
(delq nil
(mapcar
(lambda (f)
(if (file-exists-p f)
f))
(let ((root (rubocop-project-root)))
(mapcar
(lambda (f)
(expand-file-name f root))
rubocop-config-file-names))))))

(defun rubocop-buffer-name (file-or-dir)
"Generate a name for the RuboCop buffer from FILE-OR-DIR."
(concat "*RuboCop " file-or-dir "*"))
Expand All @@ -110,6 +129,10 @@ When NO-ERROR is non-nil returns nil instead of raise an error."
(defun rubocop-build-command (command path)
"Build the full command to be run based on COMMAND and PATH.
The command will be prefixed with `bundle exec` if RuboCop is bundled."
(let ((cfile (rubocop-config-file)))
(setq command (if cfile
(concat command " -c " cfile)
command)))
(concat
(if (rubocop-bundled-p) "bundle exec " "")
command
Expand Down