Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert JSON generated by Faux Pas to a format understood by PuncoverPlugin.
#!/usr/bin/env ruby
require 'rubygems'
require 'date'
require 'json'
input = JSON.parse(ARGF.read)
output = { 'meta' => { 'timestamp' => DateTime.now.strftime('%Y-%m-%d %H:%M:%S.%6N') } }
symbols = {}
input['diagnostics'].each do |diag|
file = diag['file']
next unless file
file = file.sub(Dir.pwd + '/', '')
symbol = { 'line' => diag['extent']['start']['line'],
'long_text' => diag['ruleDescription'],
'short_text' => diag['ruleShortName'] }
if symbols.has_key?(file)
symbols[file] << symbol
else
symbols[file] = [ symbol ]
end
end
output['symbols_by_file'] = symbols
File.open('.gutter.json', 'w') { |file| file.write(output.to_json) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.