mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-06 12:44:23 +08:00
Better phpstan default configuration (#2444)
* Use phpstan config file as default whenever possible + report as error
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
" Set to change the ruleset
|
||||
let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpstan')
|
||||
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
|
||||
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '')
|
||||
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
|
||||
|
||||
function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
|
||||
@@ -12,14 +12,26 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort
|
||||
\ ? ' -c ' . l:configuration
|
||||
\ : ''
|
||||
|
||||
let l:level = ale#Var(a:buffer, 'php_phpstan_level')
|
||||
let l:config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon')
|
||||
|
||||
if empty(l:level) && empty(l:config_file_exists)
|
||||
" if no configuration file is found, then use 4 as a default level
|
||||
let l:level = '4'
|
||||
endif
|
||||
|
||||
let l:level_option = !empty(l:level)
|
||||
\ ? ' -l ' . l:level
|
||||
\ : ''
|
||||
|
||||
let l:error_format = ale#semver#GTE(a:version, [0, 10, 3])
|
||||
\ ? ' --error-format raw'
|
||||
\ : ' --errorFormat raw'
|
||||
|
||||
return '%e analyze -l'
|
||||
\ . ale#Var(a:buffer, 'php_phpstan_level')
|
||||
return '%e analyze --no-progress'
|
||||
\ . l:error_format
|
||||
\ . l:configuration_option
|
||||
\ . l:level_option
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
@@ -35,7 +47,7 @@ function! ale_linters#php#phpstan#Handle(buffer, lines) abort
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'W',
|
||||
\ 'type': 'E',
|
||||
\})
|
||||
endfor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user