Improve PyLintAdapter to match more results
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
class PyLintAdapter < TestingFrameworkAdapter
|
class PyLintAdapter < TestingFrameworkAdapter
|
||||||
REGEXP = /Your code has been rated at (-?\d+\.?\d*)\/(\d+\.?\d*)/
|
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
|
def self.framework_name
|
||||||
'PyLint'
|
'PyLint'
|
||||||
@ -21,19 +21,22 @@ class PyLintAdapter < TestingFrameworkAdapter
|
|||||||
begin
|
begin
|
||||||
assertion_error_matches = Timeout.timeout(2.seconds) do
|
assertion_error_matches = Timeout.timeout(2.seconds) do
|
||||||
output[:stdout].scan(ASSERTION_ERROR_REGEXP).map do |match|
|
output[:stdout].scan(ASSERTION_ERROR_REGEXP).map do |match|
|
||||||
file_name = match.first.strip
|
{
|
||||||
line_no = match.second.strip
|
file_name: match[0].strip,
|
||||||
test = match.third.strip
|
line: match[1].to_i,
|
||||||
# e.g. function name, nil if outside of a function. Not always available
|
severity: match[2].strip,
|
||||||
context = match.fourth.strip.presence
|
code: match[3].strip,
|
||||||
description = match.fifth.strip
|
name: match[4].strip,
|
||||||
{test: test, description: description, context: context, line: line_no, file: file_name}
|
# e.g. function name, nil if outside of a function. Not always available
|
||||||
|
scope: match[5].strip.presence,
|
||||||
|
result: match[6].strip
|
||||||
|
}
|
||||||
end || []
|
end || []
|
||||||
end
|
end
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
assertion_error_matches = []
|
assertion_error_matches = []
|
||||||
end
|
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}
|
{count: count, failed: failed, error_messages: concatenated_errors, detailed_linter_results: assertion_error_matches}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user