mirror of
https://github.com/dense-analysis/ale
synced 2024-12-29 17:42:17 +00:00
2cfa09e02d
See: https://github.com/testdouble/standard StandardRB is to RuboCop what StandardJS is to ESLint. This commit naively copies the RuboCop linter and fixer to point at the standardrb executable. Any other adjustments are very minor (the only I can think of is that standardrb takes a `--fix` option instead of `--auto-correct`). This raises a confusing point to me as both developer and a user: since ale enables all linters by default, won't this run both RuboCop and StandardRB (the results of which will almost always be in conflict with one another)? How does ale already solve for this for the similar case of StandardJS and ESLint?
55 lines
1.7 KiB
Plaintext
55 lines
1.7 KiB
Plaintext
Before:
|
|
Save g:ale_ruby_standardrb_executable
|
|
Save g:ale_ruby_standardrb_options
|
|
|
|
" Use an invalid global executable, so we don't match it.
|
|
let g:ale_ruby_standardrb_executable = 'xxxinvalid'
|
|
let g:ale_ruby_standardrb_options = ''
|
|
|
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
|
silent cd ..
|
|
silent cd command_callback
|
|
let g:dir = getcwd()
|
|
|
|
After:
|
|
Restore
|
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
Execute(The standardrb callback should return the correct default values):
|
|
call ale#test#SetFilename('ruby_paths/dummy.rb')
|
|
|
|
AssertEqual
|
|
\ {
|
|
\ 'read_temporary_file': 1,
|
|
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
|
|
\ . ' --fix --force-exclusion %t',
|
|
\ },
|
|
\ ale#fixers#standardrb#Fix(bufnr(''))
|
|
|
|
Execute(The standardrb callback should include configuration files):
|
|
call ale#test#SetFilename('ruby_paths/with_config/dummy.rb')
|
|
|
|
AssertEqual
|
|
\ {
|
|
\ 'read_temporary_file': 1,
|
|
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
|
|
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.standard.yml'))
|
|
\ . ' --fix --force-exclusion %t',
|
|
\ },
|
|
\ ale#fixers#standardrb#Fix(bufnr(''))
|
|
|
|
Execute(The standardrb callback should include custom rubocop options):
|
|
let g:ale_ruby_standardrb_options = '--except Lint/Debugger'
|
|
call ale#test#SetFilename('ruby_paths/with_config/dummy.rb')
|
|
|
|
AssertEqual
|
|
\ {
|
|
\ 'read_temporary_file': 1,
|
|
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
|
|
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.standard.yml'))
|
|
\ . ' --except Lint/Debugger'
|
|
\ . ' --fix --force-exclusion %t',
|
|
\ },
|
|
\ ale#fixers#standardrb#Fix(bufnr(''))
|