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)