From c6aae3bcfcba862028180ca6ff04242c309a767a Mon Sep 17 00:00:00 2001 From: Julien Deniau Date: Thu, 2 May 2019 00:14:39 +0200 Subject: Better phpstan default configuration (#2444) * Use phpstan config file as default whenever possible + report as error --- ale_linters/php/phpstan.vim | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'ale_linters/php') diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim index ecd80a83..ca12211c 100644 --- a/ale_linters/php/phpstan.vim +++ b/ale_linters/php/phpstan.vim @@ -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 -- cgit debian/1.2.3+git2.25.1-1-2-gaceb0