Ale: Ale fix on save ignores ale enabled

Created on 30 Jan 2019  路  9Comments  路  Source: dense-analysis/ale

Information

VIM version

NVIM v0.3.2-dev
Build type: Release

Operating System: OSX

What went wrong

Ale still fixes things even though I've disabled it.

Reproducing the bug

  1. Enable ale with auto fixing
let g:ale_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_completion_enabled = 1
  1. Open a file and turn off Ale
:ALEDisable
  1. The errors are still being auto fixed when saving a file

:ALEInfo

 Current Filetype: ruby
Available Linters: ['brakeman', 'rails_best_practices', 'reek', 'rubocop', 'ruby', 'solargraph']
  Enabled Linters: ['brakeman', 'rails_best_practices', 'reek', 'rubocop', 'ruby', 'solargraph']
 Suggested Fixers: 
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'rubocop' - Fix ruby files with rubocop --auto-correct.
  'rufo' - Fix ruby files with rufo
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 Linter Variables:

let g:ale_ruby_brakeman_executable = 'brakeman'
let g:ale_ruby_brakeman_options = ''
let g:ale_ruby_reek_executable = 'reek'
let g:ale_ruby_reek_options = ''
let g:ale_ruby_reek_show_context = 0
let g:ale_ruby_reek_show_wiki_link = 0
let g:ale_ruby_rubocop_executable = 'rubocop'
let g:ale_ruby_rubocop_options = ''
let g:ale_ruby_ruby_executable = 'ruby'
let g:ale_ruby_solargraph_executable = 'solargraph'
let g:ale_ruby_solargraph_options = {}
 Global Variables:

let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 0
let g:ale_fix_on_save = 1
let g:ale_fixers = {'scss': ['stylelint'], 'erb': ['erb', 'tidy'], 'ruby': ['rubocop'], 'javascript': ['prettier', 'eslint'], 'css': ['stylelint', 'prettier']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 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_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'css': ['stylelint'], 'slim': ['stylelint']}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 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_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
  Command History:

(executable check - failure) brakeman
(executable check - failure) rails_best_practices
(executable check - failure) reek
(executable check - success) rubocop
(started) ['/bin/zsh', '-c', '''rubocop'' --format json --force-exclusion  --stdin ''/path/to/some/folder/configuration.rb'' < ''/var/folders/tz/m5bm55bj4x3fbrv00kcjp8_00000gn/T/nvimaxEw1z/8/configuration.rb''']
(executable check - success) ruby
(finished - exit code 0) ['/bin/zsh', '-c', '''ruby'' -w -c -T1 ''/var/folders/tz/m5bm55bj4x3fbrv00kcjp8_00000gn/T/nvimaxEw1z/9/configuration.rb''']

<<<NO OUTPUT RETURNED>>>

(executable check - failure) reek
(finished - exit code 0) ['/bin/zsh', '-c', '''rubocop'' --format json --force-exclusion  --stdin ''/path/to/some/folder/configuration.rb'' < ''/var/folders/tz/m5bm55bj4x3fbrv00kcjp8_00000gn/T/nvimaxEw1z/11/configuration.rb''']

<<<OUTPUT STARTS>>>
{"metadata":{"rubocop_version":"0.63.0","ruby_engine":"ruby","ruby_version":"2.5.1","ruby_patchlevel":"57","ruby_platform":"x86_64-darwin18"},"files":[],"summary":{"offense_count":0,"target_file_count":0,"inspected_file_count":0}}
<<<OUTPUT ENDS>>>

(finished - exit code 0) ['/bin/zsh', '-c', '''ruby'' -w -c -T1 ''/var/folders/tz/m5bm55bj4x3fbrv00kcjp8_00000gn/T/nvimaxEw1z/12/configuration.rb''']

<<<NO OUTPUT RETURNED>>>

(finished - exit code 1) ['/bin/zsh', '-c', '''rubocop'' --config ''/path/to/some/folder/.rubocop.yml'' --auto-correct --force-exclusion ''/var/folders/tz/m5bm55bj4x3fbrv00kcjp8_00000gn/T/nvimaxEw1z/13/configuration.rb''']

Most helpful comment

For some history, :ALEDisable existed before ALE fixed files, and its job is to set g:ale_enabled to 0 and clear the results for linting. :ALEFix was added after that, and is entirely separate from linting. It won't ever disable fixing of files.

OK, now let's analyse from the end user perspective:

  • User installs ALE and sets it to fix files with prettier _(installed globally)_;
  • User has to submit a PR to a project not-using prettier;
  • User saves the file to find out that, it not only changed their 1-line brilliant commit, but in fact, reformatted 1023陆 lines of code;
  • User thinks: _鈥渉m, let me disable Ale then, simplezz...鈥漘; user calls for :ALEDisable or :ALEToggle;
  • User gets frustrated because ALE still runs even though it should be disabled _(:ALE...Disable anyone?)_;
  • User finds issue #2260 and reads that should be aware of the entire history of Ale and know that ALEDisable came before ALEFix and it's their obligation to know that it won't really disable Ale, but only disable linting;
  • User gets a bit frustrated _(again?)_ and writes this comment with bit of sarcasm, and huge appreciation for the Ale project and how it's a blessing in many developers lives, wondering if this decision could be reviewed and included as a default for ALEDisable|Toggle.

All 9 comments

Maybe the best approach would be to turn off g:ale_fix_on_save when calling ALEDisable. I can write a PR for that, but let me know if you'd approve that.

:ALEDisable is for linting only by design. This is working as intended. See :help ALEDisable.

For some history, :ALEDisable existed before ALE fixed files, and its job is to set g:ale_enabled to 0 and clear the results for linting. :ALEFix was added after that, and is entirely separate from linting. It won't ever disable fixing of files.

Thank you for your clarification and quick response!

What do you think about adding ALEFixDisable or even ALEDisableAll that would disable both fixing and linting?

I don't think there's a need for it to exist in the plugin itself. You can write :ALEDisable | let g:ale_fix_on_save = 0 to do both. It's the same for disabling completion. :ALEDisable does more than just set g:ale_enabled = 0, because it also clears all of the results and stops all of the jobs that are still running, so there's a need for it.

Gotcha, thank you! Thanks for writing the plugin in the first place, it's super helpful.

I ran into this today as well and came looking here for a solution. It's clearly a RTFM fault on my part, but surprising nonetheless.

I run into this all the time. I really wish there was an easy master kill switch!

For some history, :ALEDisable existed before ALE fixed files, and its job is to set g:ale_enabled to 0 and clear the results for linting. :ALEFix was added after that, and is entirely separate from linting. It won't ever disable fixing of files.

OK, now let's analyse from the end user perspective:

  • User installs ALE and sets it to fix files with prettier _(installed globally)_;
  • User has to submit a PR to a project not-using prettier;
  • User saves the file to find out that, it not only changed their 1-line brilliant commit, but in fact, reformatted 1023陆 lines of code;
  • User thinks: _鈥渉m, let me disable Ale then, simplezz...鈥漘; user calls for :ALEDisable or :ALEToggle;
  • User gets frustrated because ALE still runs even though it should be disabled _(:ALE...Disable anyone?)_;
  • User finds issue #2260 and reads that should be aware of the entire history of Ale and know that ALEDisable came before ALEFix and it's their obligation to know that it won't really disable Ale, but only disable linting;
  • User gets a bit frustrated _(again?)_ and writes this comment with bit of sarcasm, and huge appreciation for the Ale project and how it's a blessing in many developers lives, wondering if this decision could be reviewed and included as a default for ALEDisable|Toggle.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

EdmundsEcho picture EdmundsEcho  路  3Comments

chauncey-garrett picture chauncey-garrett  路  3Comments

plexigras picture plexigras  路  3Comments

trevordmiller picture trevordmiller  路  4Comments

trevordmiller picture trevordmiller  路  3Comments