dense-analysis / dense-analysis/ale

ERB linter has erroneous errors in at least ruby 3.1.2

Open
#4,167 4 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

## Information

**VIM version**

NVIM v0.7.0
Build type: Release

Operating System: macOS 12.3.1

## What went wrong

Ruby 3.1.2 (and maybe all Ruby 3.x versions) have a deprecation message when using the eruby ALE linter in rails applications.

Specifically, the error message you get is:

`Passing trim_mode with the 3rd argument of erb.new is deprecated`.

This error message seems to come from [ale itself](https://github.com/dense-analysis/ale/blob/6c51bb1573f0bf5deff04508769208fd503b5ff7/ale_linters/eruby/erb.vim#L14) and can be fixed by perhaps splitting based on ruby versions to use the older signature in older rubies and the newer signature in newer rubies.

## Reproducing the bug

1. Have a clone of a ruby application running ruby 3.1.2 and requisite dependencies
2. Open an erb file
3. Notice that _all_ erb files have an error on the first line with the message `Passing trim_mode with the 3rd argument of erb.new is deprecated`

### :ALEInfo

```
Current Filetype: eruby
Available Linters: ['erb', 'erblint', 'erubi', 'erubis', 'ruumba']
Linter Aliases:
'erb' -> ['erubylint']
Enabled Linters: ['erb', 'erblint', 'erubi', 'erubis', 'ruumba']
Ignored Linters: []
Suggested Fixers:
'erblint' - Apply erblint --autocorrect to a file.
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:

let g:ale_eruby_erblint_executable = 'erblint'
let g:ale_eruby_erblint_options = ''
let g:ale_eruby_ruumba_executable = 'ruumba'
let g:ale_eruby_ruumba_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 = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 0
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 = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {'go': ['gofmt'], 'ruby': ['standardrb'], 'javascript': ['prettier'], 'css': ['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 = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {'ruby': ['rubocop']}
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_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 0
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
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_sign_highlight_linenrs = 0
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 - success) erb
(started) ['/bin/zsh', '-c', 'ruby -r erb -e ''puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src''< ''/var/folders/6v/d3rhg9yd7vq4dpx9fbj2v9hh0000gn/T/nvimtnUgQQ/29/new.html.erb'' | ruby -c']
(executable check - failure) erblint
(started) ['/bin/zsh', '-c', 'ruby -r erubi/capture_end -e ''""''']
(executable check - failure) erubis
(executable check - failure) ruumba
(finished - exit code 0) ['/bin/zsh', '-c', 'ruby -r erb -e ''puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src''< ''/var/folders/6v/d3rhg9yd7vq4dpx9fbj2v9hh0000gn/T/nvimtnUgQQ/30/new.html.erb'' | ruby -c']

<<>>
-e:1: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
-e:1: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.
<<>>

(executable check - failure) erblint
(finished - exit code 0) ['/bin/zsh', '-c', 'ruby -r erubi/capture_end -e ''""''']

<<>>

(executable check - failure) erubis
(executable check - failure) ruumba
(finished - exit code 0) ['/bin/zsh', '-c', 'ruby -r erubi/capture_end -e ''puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src''< ''/var/folders/6v/d3rhg9yd7vq4dpx9fbj2v9hh0000gn/T/nvimtnUgQQ/31/new.html.erb'' | ruby -c']

<<>>
Syntax OK
<<>>
```

I think the problem is in this line `(finished - exit code 0) ['/bin/zsh', '-c', 'ruby -r erb -e ''puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src''< ''/var/folders/6v/d3rhg9yd7vq4dpx9fbj2v9hh0000gn/T/nvimtnUgQQ/30/new.html.erb'' | ruby -c']`. The deprecation messages are also visible in the log.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.