From bca8cc2c8666312a71012742dbef076f0846c281 Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Sun, 5 Apr 2015 04:05:52 -0400 Subject: [PATCH] Ignore errors not in linted file Fixes SublimeLinter/SublimeLinter3#227 --- linter.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/linter.py b/linter.py index b2d863e..74f9a23 100644 --- a/linter.py +++ b/linter.py @@ -20,8 +20,23 @@ class Ruby(RubyLinter): syntax = ('ruby', 'ruby on rails', 'rspec') cmd = 'ruby -wc' regex = ( - r'^.+?:(?P\d+): (?:(?P.*?error)|(?Pwarning))[,:] (?P[^\r\n]+)\r?\n' + r'^(?P.+?):(?P\d+): (?:(?P.*?error)|(?Pwarning))[,:] (?P[^\r\n]+)\r?\n' r'(?:^[^\r\n]+\r?\n^(?P.*?)\^)?' ) multiline = True comment_re = r'\s*#' + + def split_match(self, match): + """ + Return the components of the match. + + We override this because unrelated library files can throw errors, + and we only want errors from the linted file. + + """ + + if match: + if match.group('file') != '-': + match = None + + return super().split_match(match)