#977 Complain about the lack of configuration files for scalastyle in such a way that users will be directed towards getting it to work

This commit is contained in:
w0rp 2017-10-15 00:20:43 +01:00
parent 515dcdef29
commit 90d4fb139c
3 changed files with 41 additions and 4 deletions

View File

@ -8,10 +8,21 @@ let g:ale_scalastyle_config_loc =
\ get(g:, 'ale_scalastyle_config_loc', '') \ get(g:, 'ale_scalastyle_config_loc', '')
function! ale_linters#scala#scalastyle#Handle(buffer, lines) abort function! ale_linters#scala#scalastyle#Handle(buffer, lines) abort
" Look for help output from scalastyle first, which indicates that no
" configuration file was found.
for l:line in a:lines[:10]
if l:line =~# '-c, --config'
return [{
\ 'lnum': 1,
\ 'text': '(See :help ale-scala-scalastyle)'
\ . ' No scalastyle configuration file was found.',
\}]
endif
endfor
" Matches patterns like the following: " Matches patterns like the following:
" "
" warning file=/home/blurble/Doop.scala message=Missing or badly formed ScalaDoc: Extra @param foobles line=190 " warning file=/home/blurble/Doop.scala message=Missing or badly formed ScalaDoc: Extra @param foobles line=190
let l:patterns = [ let l:patterns = [
\ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\)$', \ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\)$',
\ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\) column=\(\d\+\)$', \ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\) column=\(\d\+\)$',

View File

@ -5,6 +5,17 @@ ALE Scala Integration *ale-scala-options*
=============================================================================== ===============================================================================
scalastyle *ale-scala-scalastyle* scalastyle *ale-scala-scalastyle*
`scalastyle` requires a configuration file for a project to run. When no
configuration file can be found, ALE will report a problem saying that a
configuration file is required at line 1.
To disable `scalastyle` globally, use |g:ale_linters| like so: >
let g:ale_linters = {'scala': ['scalac']} " Enable only scalac instead
<
See |g:ale_linters| for more information on disabling linters.
g:ale_scalastyle_config_loc *g:ale_scalastyle_config_loc* g:ale_scalastyle_config_loc *g:ale_scalastyle_config_loc*
Type: |String| Type: |String|

View File

@ -1,6 +1,10 @@
Execute(The scalastyle handler should parse lines correctly): Before:
runtime! ale_linters/scala/scalastyle.vim runtime! ale_linters/scala/scalastyle.vim
After:
call ale#linter#Reset()
Execute(The scalastyle handler should parse lines correctly):
AssertEqual AssertEqual
\ [ \ [
\ { \ {
@ -34,5 +38,16 @@ Execute(The scalastyle handler should parse lines correctly):
\ 'Finished in 934 ms', \ 'Finished in 934 ms',
\ ]) \ ])
After: Execute(The scalastyle linter should complain when there is no configuration file):
call ale#linter#Reset() AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'text': '(See :help ale-scala-scalastyle) No scalastyle configuration file was found.',
\ },
\ ],
\ ale_linters#scala#scalastyle#Handle(347, [
\ 'scalastyle 1.0.0',
\ 'Usage: scalastyle [options] <source directory>',
\ ' -c, --config FILE configuration file (required)',
\ ])