mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-19 01:22:57 +08:00
Add initial ameba (crystal linter) support (#2174)
* Add initial ameba (crystal linter) support Note that this depends on saved file as `ameba` does not have STDIN support * Fix formatting of crystal linter documentation * Add tests for ameba executable customization
This commit is contained in:
20
test/command_callback/test_ameba_command_callback.vader
Normal file
20
test/command_callback/test_ameba_command_callback.vader
Normal file
@@ -0,0 +1,20 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('crystal', 'ameba')
|
||||
call ale#test#SetFilename('dummy.cr')
|
||||
|
||||
let g:ale_crystal_ameba_executable = 'bin/ameba'
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(Executable should default to bin/ameba):
|
||||
AssertLinter 'bin/ameba', ale#Escape('bin/ameba')
|
||||
\ . ' --format json '
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.cr'))
|
||||
|
||||
Execute(Should be able to set a custom executable):
|
||||
let g:ale_crystal_ameba_executable = 'ameba'
|
||||
|
||||
AssertLinter 'ameba' , ale#Escape('ameba')
|
||||
\ . ' --format json '
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.cr'))
|
||||
44
test/handler/test_ameba_handler.vader
Normal file
44
test/handler/test_ameba_handler.vader
Normal file
@@ -0,0 +1,44 @@
|
||||
Before:
|
||||
runtime ale_linters/crystal/ameba.vim
|
||||
|
||||
After:
|
||||
unlet! g:lines
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The ameba handler should parse lines correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 24,
|
||||
\ 'col': 28,
|
||||
\ 'end_col': 29,
|
||||
\ 'text': 'Trailing whitespace detected',
|
||||
\ 'code': 'Layout/TrailingWhitespace',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#crystal#ameba#HandleAmebaOutput(123, [
|
||||
\ '{"sources":[{"path":"my_file_with_issues.cr","issues":[{"rule_name":"Layout/TrailingWhitespace","message":"Trailing whitespace detected","location":{"line":24,"column":28},"end_location":{"line":null,"column":null}}]},{"path":"my_file_without_issues.cr","issues":[]}],"metadata":{"ameba_version":"0.8.1","crystal_version":"0.26.1"},"summary":{"target_sources_count":2,"issues_count":1}}'
|
||||
\ ])
|
||||
|
||||
Execute(The ameba handler should handle when files are checked and no offenses are found):
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#crystal#ameba#HandleAmebaOutput(123, [
|
||||
\ '{"sources":[{"path":"my_file_with_issues.cr",issues":[]},{"path":"my_file_without_issues.cr",issues":[]}],"metadata":{ameba_version":"0.8.1",crystal_version":"0.26.1"},"summary":{target_sources_count":2,issues_count":0}}'
|
||||
\ ])
|
||||
|
||||
Execute(The ameba handler should handle when no files are checked):
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#crystal#ameba#HandleAmebaOutput(123, [
|
||||
\ '{"sources":[],"metadata":{ameba_version":"0.8.1",crystal_version":"0.26.1"},"summary":{target_sources_count":0,issues_count":0}}'
|
||||
\ ])
|
||||
|
||||
Execute(The ameba handler should handle blank output without any errors):
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#crystal#ameba#HandleAmebaOutput(123, ['{}'])
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#crystal#ameba#HandleAmebaOutput(123, [])
|
||||
Reference in New Issue
Block a user