diff --git a/lib/py_lint_adapter.rb b/lib/py_lint_adapter.rb index 828586c8..2447b37a 100644 --- a/lib/py_lint_adapter.rb +++ b/lib/py_lint_adapter.rb @@ -1,6 +1,6 @@ class PyLintAdapter < TestingFrameworkAdapter REGEXP = /Your code has been rated at (-?\d+\.?\d*)\/(\d+\.?\d*)/ - ASSERTION_ERROR_REGEXP = /^(.*?\.py):(\d+):.*?\([^,]*?,\ ([^,]*?),([^,]*?)\)\ (.*?)$/ + ASSERTION_ERROR_REGEXP = /^(.*?\.py):(\d+):(.*?)\(([^,]*?), ([^,]*?),([^,]*?)\) (.*?)$/ def self.framework_name 'PyLint' @@ -21,19 +21,22 @@ class PyLintAdapter < TestingFrameworkAdapter begin assertion_error_matches = Timeout.timeout(2.seconds) do output[:stdout].scan(ASSERTION_ERROR_REGEXP).map do |match| - file_name = match.first.strip - line_no = match.second.strip - test = match.third.strip - # e.g. function name, nil if outside of a function. Not always available - context = match.fourth.strip.presence - description = match.fifth.strip - {test: test, description: description, context: context, line: line_no, file: file_name} + { + file_name: match[0].strip, + line: match[1].to_i, + severity: match[2].strip, + code: match[3].strip, + name: match[4].strip, + # e.g. function name, nil if outside of a function. Not always available + scope: match[5].strip.presence, + result: match[6].strip + } end || [] end rescue Timeout::Error assertion_error_matches = [] end - concatenated_errors = assertion_error_matches.map { |result| "#{result[:test]}: #{result[:description]}" }.flatten + concatenated_errors = assertion_error_matches.map { |result| "#{result[:name]}: #{result[:result]}" }.flatten {count: count, failed: failed, error_messages: concatenated_errors, detailed_linter_results: assertion_error_matches} end end