Ale: ALE doesn't fix certain files with rubocop

Created on 6 Jul 2017  ·  19Comments  ·  Source: dense-analysis/ale

ALEInfo:

 Current Filetype: vim
Available Linters: ['vint']
  Enabled Linters: ['vint']
 Linter Variables:

let g:ale_vim_vint_show_style_issues = 1
 Global Variables:

let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_enabled = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'jsx': ['eslint', 'flow'], 'hcl': [], 'ruby': ['ruby', 'rubocop'], 'javascript': ['eslint', 'flow'], 'python': ['flake8']}
let g:ale_open_list = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 1
let g:ale_sign_error = '🚫'
let g:ale_sign_offset = 1000000
let g:ale_sign_warning = '✋'
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

Ale-fixer configs (not in ALEInfo, see #731 ):

let g:ale_fixers = {
\   'javascript': ['prettier'],
\   'ruby': ['rubocop'],
\}
let g:ale_enabled = 1
let g:ale_fix_on_save = 1

I can't seem to get this to do anything when I save - I also don't see the command in the command history from ALEInfo, both for rubocop and prettier.

I'm super pumped to use the fix feature, but I just must be doing something wrong! Thanks :)

bug

All 19 comments

The command isn't currently added to the history for fixing files. Can you run either command from the command line?

You can also use the :ALEFix command to fix things. I personally use this instead of fixing files on save.

@w0rp what do you mean by "Can you run either command from the command line"?

rubocop --auto-correct works as expected outside of vim, but I can't tell whether it's doing anything from ale.

I also tried :ALEFix, but nothing seems to happen. Tried verbose vim logging as well, if that's helpful.

Searching for "~/.vim/plugged/ale/autoload/ale/fixers/rubocop.vim"
chdir(~/.vim/plugged/ale/autoload/ale/fixers)
fchdir() to previous dir
line 11: sourcing "~/.vim/plugged/ale/autoload/ale/fixers/rubocop.vim"
finished sourcing ~/.vim/plugged/ale/autoload/ale/fixers/rubocop.vim
continuing in ~/code/dotfiles/vim/plugged/ale/autoload/ale/fixers/rubocop.vim
finished sourcing ~/.vim/plugged/ale/autoload/ale/fixers/rubocop.vim
continuing in function ale#fix#Fix[32]..<SNR>102_RunFixer[8]..ale#util#FunctionArgCount
   function ale#fixers#rubocop#Fix(buffer) abort
        Last set from ~/code/dotfiles/vim/plugged/ale/autoload/ale/fixers/rubocop.vim
1      return {   'command': ale#fixers#rubocop#GetCommand(a:buffer),   'read_temporary_file': 1,}
   endfunction
chdir(app/models)
fchdir() to previous dir

But it's not actually fixing what it should be, and I don't see a log line for the actual rubocop exec. Thanks for the help

Also - rubocop linting is working fine with ale, just not the fixer

UPDATE: I did get prettier to work but rubocop is still not doing anything.

Here's my (new) config:

let g:ale_fixers = {
\   'javascript': ['prettier'],
\   'ruby': ['rubocop'],
\}
let g:ale_javascript_prettier_options = ' --parser babylon --single-quote --jsx-bracket-same-line --trailing-comma es5 --print-width 100'
let g:ale_enabled = 1

I'm trying to install rubocop now to try it myself. I'm not a Ruby user, so this will take me a little while.

Thank you thank you!! I'm on rubocop version 0.49.1, and ruby 2.4.1p111 if that helps

That does, cheers! I'll test it with those versions.

ok, making progress - I think it has something to do with detecting the .rubocop.yml file correctly...

When I update the options to be

let g:ale_ruby_rubocop_options = ' --only Style/StringLiterals'

just to test a simple rule that is easy to brute-force -- and that worked! Not sure how detection of the config file works, but my guess is that it's not loading it properly in the root directory

What's the output of :!rubocop --version, versus what you see in the command line?

same, 0.49.1

It might be nice to add support for searching for executables in ~/.rbenv/shims/ at some point. I suppose I can configure the executable for now.

BTW, if it's easier for you, you can jump on #vim-ale in Freenode IRC.

The issue here was that it wasn't using the configuration files. Now it is.

Hum, I've the same problem with neovim, RuboCop 0.57.2. I've a config file named .rubocop.yml at my projects root.

When I save with :w nothing happen, when I do :ALEFix it works.

And it seems to be linting correctly.

Did you set let b:ale_fix_on_save = 1 in your ftplugin file, or let g:ale_fix_on_save = 1 in your vimrc file?

Yes I did, actually, it seems reek isn’t taking the config file as well.

Any way I can show a debug mode to see what is executed?

I’m new to vim. Not sure where to look.

On 3 Jul 2018, at 21.29, w0rp notifications@github.com wrote:

Did you set let b:ale_fix_on_save = 1 in your ftplugin file, or let g:ale_fix_on_save = 1 in your vimrc file?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Check out the output of :ALEInfo for the output ALE captures. If you are using Vim, use :call ch_logfile(expand('~/channel.log'), 'w') to create a file which logs _all_ of the activity for channels and jobs, so you can see everything that Vim is doing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trevordmiller picture trevordmiller  ·  3Comments

janhellmich picture janhellmich  ·  3Comments

alexlafroscia picture alexlafroscia  ·  4Comments

ianchanning picture ianchanning  ·  3Comments

trevordmiller picture trevordmiller  ·  4Comments