diff options
author | Eddie Lebow <elebow@users.noreply.github.com> | 2017-07-12 19:42:54 -0400 |
---|---|---|
committer | Eddie Lebow <elebow@users.noreply.github.com> | 2017-07-12 19:53:58 -0400 |
commit | dcbb0ffee536754df014085b03bf65cd2c21150f (patch) | |
tree | 6ac1a2b6c87e98e953f7fbdd45994ab14ce061c2 /test/handler/test_rubocop_handler.vader | |
parent | 588595419739e3fec9cad921824e0e07aadb440d (diff) | |
download | ale-dcbb0ffee536754df014085b03bf65cd2c21150f.zip |
Rubocop: handle empty 'files' array in output
The handler previously assumed there would be at least one entry in the
'files' array in the output JSON. It looks like this in the normal case:
"files":[{"path":"app/models/image.rb","offenses":[]}]
But if RuboCop's config excludes the specified input files, causing no
files to be linted, the output is emptier:
"files":[]
This change causes the handler to treat that case correctly, and also
exit early if the reported offense_count is zero.
Diffstat (limited to 'test/handler/test_rubocop_handler.vader')
-rw-r--r-- | test/handler/test_rubocop_handler.vader | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/handler/test_rubocop_handler.vader b/test/handler/test_rubocop_handler.vader index 3b447394..a6320014 100644 --- a/test/handler/test_rubocop_handler.vader +++ b/test/handler/test_rubocop_handler.vader @@ -41,6 +41,20 @@ Execute(The rubocop handler should parse lines correctly): \ '{"metadata":{"rubocop_version":"0.47.1","ruby_engine":"ruby","ruby_version":"2.1.5","ruby_patchlevel":"273","ruby_platform":"x86_64-linux-gnu"},"files":[{"path":"my_great_file.rb","offenses":[{"severity":"convention","message":"Prefer single-quoted strings...","cop_name":"Style/SomeCop","corrected":false,"location":{"line":83,"column":29,"length":7}},{"severity":"fatal","message":"Some error","cop_name":"Style/SomeOtherCop","corrected":false,"location":{"line":12,"column":2,"length":1}},{"severity":"warning","message":"Regular warning","cop_name":"Style/WarningCop","corrected":false,"location":{"line":10,"column":5,"length":8}},{"severity":"error","message":"Another error","cop_name":"Style/SpaceBeforeBlockBraces","corrected":false,"location":{"line":11,"column":1,"length":1}}]}],"summary":{"offense_count":4,"target_file_count":1,"inspected_file_count":1}}' \ ]) +Execute(The rubocop handler should handle when files are checked and no offenses are found): + AssertEqual + \ [], + \ ale_linters#ruby#rubocop#Handle(347, [ + \ '{"metadata":{"rubocop_version":"0.47.1","ruby_engine":"ruby","ruby_version":"2.1.5","ruby_patchlevel":"273","ruby_platform":"x86_64-linux-gnu"},"files":[{"path":"my_great_file.rb","offenses":[]}],"summary":{"offense_count":0,"target_file_count":1,"inspected_file_count":1}}' + \ ]) + +Execute(The rubocop handler should handle when no files are checked): + AssertEqual + \ [], + \ ale_linters#ruby#rubocop#Handle(347, [ + \ '{"metadata":{"rubocop_version":"0.47.1","ruby_engine":"ruby","ruby_version":"2.1.5","ruby_patchlevel":"273","ruby_platform":"x86_64-linux-gnu"},"files":[],"summary":{"offense_count":0,"target_file_count":0,"inspected_file_count":0}}' + \ ]) + Execute(Parse errors should be handled for rubocop): let g:lines = [ \ '/my/project/.rubocop.yml: Layout/MultilineOperationIndentation has the wrong namespace - should be Style', |