eb6a7b7516
Checkstyle xml configuration is mandatory and not providing one causes the tool to fail with the following error: Must specify a config XML file. Checkstyle itself contains a default configuration as part of its assests named `/google_checks.xml`. Invoking checkstyle with this config works even if such file does not exists in the file system: checkstyle -c /google_checks.xml This should be the default invocation to allow ALE to use checkstyle with zero configuration. Also when a user sets `g:ale_java_checkstyle_config` option, ALE should use it to invoke checkstyle even such file does not exists in the filesystem. This is because checkstyle is able to use configuration files within JAR files defined in the CLASSPATH. The default `/google_checks.xml` is an example of such configuration available within a JAR resource.
72 lines
2.3 KiB
Text
72 lines
2.3 KiB
Text
Before:
|
|
call ale#assert#SetUpLinterTest('java', 'checkstyle')
|
|
call ale#test#SetFilename('dummy.java')
|
|
|
|
After:
|
|
call ale#assert#TearDownLinterTest()
|
|
|
|
Execute(The checkstyle callback should return the correct default value):
|
|
AssertLinter 'checkstyle',
|
|
\ ale#Escape('checkstyle')
|
|
\ . ' -c ' . ale#Escape('/google_checks.xml')
|
|
\ . ' %s'
|
|
|
|
Execute(The checkstyle executable should be configurable):
|
|
let b:ale_java_checkstyle_executable = 'foobar'
|
|
|
|
AssertLinter 'foobar',
|
|
\ ale#Escape('foobar')
|
|
\ . ' -c ' . ale#Escape('/google_checks.xml')
|
|
\ . ' %s'
|
|
|
|
Execute(Custom options should be supported):
|
|
let b:ale_java_checkstyle_options = '--foobar'
|
|
|
|
AssertLinter 'checkstyle',
|
|
\ ale#Escape('checkstyle')
|
|
\ . ' --foobar'
|
|
\ . ' -c ' . ale#Escape('/google_checks.xml')
|
|
\ . ' %s'
|
|
|
|
Execute(configuration files set in _config should be supported):
|
|
let b:ale_java_checkstyle_config = ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml')
|
|
|
|
AssertLinter 'checkstyle',
|
|
\ ale#Escape('checkstyle')
|
|
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml'))
|
|
\ . ' %s'
|
|
|
|
Execute(configuration files set in _options should be preferred over _config):
|
|
let b:ale_java_checkstyle_config = '/foo.xml'
|
|
let b:ale_java_checkstyle_options = '-c /bar.xml'
|
|
|
|
AssertLinter 'checkstyle', ale#Escape('checkstyle') . ' -c /bar.xml %s'
|
|
|
|
let b:ale_java_checkstyle_options = '-x -c /bar.xml'
|
|
|
|
AssertLinter 'checkstyle', ale#Escape('checkstyle') . ' -x -c /bar.xml %s'
|
|
|
|
Execute(google_checks.xml should be used by default):
|
|
call ale#test#SetFilename('checkstyle_paths/test.java')
|
|
|
|
AssertLinter 'checkstyle',
|
|
\ ale#Escape('checkstyle')
|
|
\ . ' -c ' . ale#Escape('/google_checks.xml')
|
|
\ . ' %s'
|
|
|
|
Execute(Other relative paths should be supported):
|
|
let b:ale_java_checkstyle_config = 'checkstyle_paths/other_config.xml'
|
|
|
|
AssertLinter 'checkstyle',
|
|
\ ale#Escape('checkstyle')
|
|
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml'))
|
|
\ . ' %s'
|
|
|
|
call ale#test#SetFilename('checkstyle_paths/test.java')
|
|
|
|
let b:ale_java_checkstyle_config = 'other_config.xml'
|
|
|
|
AssertLinter 'checkstyle',
|
|
\ ale#Escape('checkstyle')
|
|
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml'))
|
|
\ . ' %s'
|