All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Kevin Kays - https://github.com/okkays
2 " Description: Support for the scalastyle checker.
4 call ale#Set('scala_scalastyle_options', '')
5 " TODO: Remove support for the old option name in ALE 3.0.
6 call ale#Set('scala_scalastyle_config',
7 \ get(g:, 'ale_scalastyle_config_loc', '')
10 function! ale_linters#scala#scalastyle#Handle(buffer, lines) abort
11 " Look for help output from scalastyle first, which indicates that no
12 " configuration file was found.
13 for l:line in a:lines[:10]
14 if l:line =~# '-c, --config'
17 \ 'text': '(See :help ale-scala-scalastyle)'
18 \ . ' No scalastyle configuration file was found.',
23 " Matches patterns like the following:
25 " warning file=/home/blurble/Doop.scala message=Missing or badly formed ScalaDoc: Extra @param foobles line=190
27 \ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\)$',
28 \ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\) column=\(\d\+\)$',
32 for l:match in ale#util#GetMatches(a:lines, l:patterns)
34 \ 'lnum': l:match[3] + 0,
35 \ 'type': l:match[1] =~? 'error' ? 'E' : 'W',
40 let l:args['col'] = l:match[4] + 1
43 call add(l:output, l:args)
49 function! ale_linters#scala#scalastyle#GetCommand(buffer) abort
50 " Search for scalastyle config in parent directories.
51 let l:scalastyle_config = ''
52 let l:potential_configs = [
53 \ 'scalastyle_config.xml',
54 \ 'scalastyle-config.xml'
57 for l:config in l:potential_configs
58 let l:scalastyle_config = ale#path#ResolveLocalPath(
64 if !empty(l:scalastyle_config)
69 " If all else fails, try the global config.
70 if empty(l:scalastyle_config)
71 let l:scalastyle_config = ale#Var(a:buffer, 'scala_scalastyle_config')
75 \ . (!empty(l:scalastyle_config) ? ' --config ' . ale#Escape(l:scalastyle_config) : '')
76 \ . ale#Pad(ale#Var(a:buffer, 'scala_scalastyle_options'))
80 call ale#linter#Define('scala', {
81 \ 'name': 'scalastyle',
82 \ 'executable': 'scalastyle',
83 \ 'output_stream': 'stdout',
84 \ 'command': function('ale_linters#scala#scalastyle#GetCommand'),
85 \ 'callback': 'ale_linters#scala#scalastyle#Handle',