mirror of
https://github.com/jimeh/rubocopfmt.el.git
synced 2026-02-19 09:06:41 +00:00
feat(cops): Add support for running unsafe cops with latest RuboCop
Latest version of RuboCop now only performs auto-corrections from "safe" cops when given the `--auto-correct`/`-a` option. To run auto-corrections from all cops, including "unsafe" ones, you must now pass in `--auto-correct-all`/`-A` instead. The new `rubocopfmt-include-unsafe-cops` defcustom defaults to no `nil`, for backwards compatibility. Turn on unsafe cops by setting it to `t`.
This commit is contained in:
13
README.md
13
README.md
@@ -45,6 +45,19 @@ Place `rubocopfmt.el` somewhere into you `load-path` and require it. For example
|
||||
With `rubocopfmt-mode` enabled, Ruby buffer will automatically be formatted with
|
||||
RuboCop on save.
|
||||
|
||||
### Unsafe Cops
|
||||
|
||||
RuboCop no longer runs auto-corrections for unsafe cops. To enable unsafe cops,
|
||||
set `rubocopfmt-include-unsafe-cops` to `t`. If you're using use-package:
|
||||
|
||||
```elisp
|
||||
(use-package rubocopfmt
|
||||
:hook
|
||||
(ruby-mode . rubocopfmt-mode)
|
||||
:custom
|
||||
(rubocopfmt-include-unsafe-cops t))
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
- `rubocopfmt` - Format current buffer with RuboCop.
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
"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.
|
||||
"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)
|
||||
@@ -89,6 +89,12 @@ inside a `before-save-hook'."
|
||||
(const :tag "None" nil))
|
||||
:group 'rubocopfmt)
|
||||
|
||||
(defcustom rubocopfmt-include-unsafe-cops nil
|
||||
"When t include unsafe cops when auto-correcting.
|
||||
Determines if --auto-correct or --auto-correct-all will be passed to rubocop."
|
||||
:type 'boolean
|
||||
:group 'rubocopfmt)
|
||||
|
||||
(defcustom rubocopfmt-major-modes '(ruby-mode enh-ruby-mode)
|
||||
"List of major modes to format on save when rubocopfmt-mode is enabled."
|
||||
:type '(repeat symbol)
|
||||
@@ -245,8 +251,10 @@ If FILE is not found in DIRECTORY, the parent of DIRECTORY will be searched."
|
||||
(src-dir (file-name-directory buffer-file))
|
||||
(src-file (file-name-nondirectory buffer-file))
|
||||
(fmt-command rubocopfmt-rubocop-command)
|
||||
(auto-correct-flag (if rubocopfmt-include-unsafe-cops
|
||||
"--auto-correct-all" "--auto-correct"))
|
||||
(fmt-args (list "--stdin" src-file
|
||||
"--auto-correct"
|
||||
auto-correct-flag
|
||||
"--format" "emacs")))
|
||||
|
||||
(if (and rubocopfmt-use-bundler-when-possible
|
||||
|
||||
Reference in New Issue
Block a user