From ab0e76dbd50dbe5bae08817baa56432889335b99 Mon Sep 17 00:00:00 2001 From: Eddie Lebow Date: Sun, 9 Jul 2017 10:48:04 -0400 Subject: Use rubocop's JSON output format (resolves #339) (#738) * Use rubocop's JSON output format (resolves #339) Rubocop's emacs formatter seems to have changed format in some not-so-ancient version. The JSON formatter should provide a more stable interface than parsing lines with a regex. The JSON formatter was introduced in mid-2013, so it should be safe to assume available in any reasonably-modern environment. The oldest currently-supported version of ruby (according to ruby-lang.org) was not supported by rubocop until 2014. * Rubocop: Use global function for GetType * Rubocop: Use scope prefix in GetType * Rubocop: Update command_callback test * Rubocop: add end_col to Handle --- test/handler/test_rubocop_handler.vader | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/handler/test_rubocop_handler.vader') diff --git a/test/handler/test_rubocop_handler.vader b/test/handler/test_rubocop_handler.vader index 8fa8374a..396ca0ed 100644 --- a/test/handler/test_rubocop_handler.vader +++ b/test/handler/test_rubocop_handler.vader @@ -6,34 +6,34 @@ Execute(The rubocop handler should parse lines correctly): \ { \ 'lnum': 83, \ 'col': 29, + \ 'end_col': 35, \ 'text': 'Prefer single-quoted strings...', \ 'type': 'W', \ }, \ { \ 'lnum': 12, \ 'col': 2, + \ 'end_col': 2, \ 'text': 'Some error', \ 'type': 'E', \ }, \ { \ 'lnum': 10, \ 'col': 5, + \ 'end_col': 12, \ 'text': 'Regular warning', \ 'type': 'W', \ }, \ { \ 'lnum': 11, \ 'col': 1, + \ 'end_col': 1, \ 'text': 'Another error', \ 'type': 'E', \ }, \ ], \ ale_linters#ruby#rubocop#Handle(347, [ - \ 'This line should be ignored completely', - \ 'whatever:83:29: C: Prefer single-quoted strings...', - \ 'whatever:12:2: F: Some error', - \ 'whatever:10:5: W: Regular warning', - \ 'whatever:11:1: E: Another error', + \ '{"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}}' \ ]) After: -- cgit v1.2.3