diff --git a/ale_linters/scala/scalastyle.vim b/ale_linters/scala/scalastyle.vim index ea56c0e..f78fd74 100644 --- a/ale_linters/scala/scalastyle.vim +++ b/ale_linters/scala/scalastyle.vim @@ -8,10 +8,21 @@ let g:ale_scalastyle_config_loc = \ get(g:, 'ale_scalastyle_config_loc', '') 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: " " warning file=/home/blurble/Doop.scala message=Missing or badly formed ScalaDoc: Extra @param foobles line=190 - let l:patterns = [ \ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\)$', \ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\) column=\(\d\+\)$', diff --git a/doc/ale-scala.txt b/doc/ale-scala.txt index 22e684f..9c9472f 100644 --- a/doc/ale-scala.txt +++ b/doc/ale-scala.txt @@ -5,6 +5,17 @@ ALE Scala Integration *ale-scala-options* =============================================================================== 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* Type: |String| diff --git a/test/handler/test_scalastyle_handler.vader b/test/handler/test_scalastyle_handler.vader index b03d18e..32da79c 100644 --- a/test/handler/test_scalastyle_handler.vader +++ b/test/handler/test_scalastyle_handler.vader @@ -1,6 +1,10 @@ -Execute(The scalastyle handler should parse lines correctly): +Before: runtime! ale_linters/scala/scalastyle.vim +After: + call ale#linter#Reset() + +Execute(The scalastyle handler should parse lines correctly): AssertEqual \ [ \ { @@ -34,5 +38,16 @@ Execute(The scalastyle handler should parse lines correctly): \ 'Finished in 934 ms', \ ]) -After: - call ale#linter#Reset() +Execute(The scalastyle linter should complain when there is no configuration file): + 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] ', + \ ' -c, --config FILE configuration file (required)', + \ ])