Skip to content

Instantly share code, notes, and snippets.

@sumyapp
Created August 15, 2016 13:15
Show Gist options
  • Save sumyapp/46f35478611c2e872fd3eacf87ca4199 to your computer and use it in GitHub Desktop.
Save sumyapp/46f35478611c2e872fd3eacf87ca4199 to your computer and use it in GitHub Desktop.
require 'json'
input_file = 'eslint_result.json'
output_file = 'eslint_todo.json'
array = JSON.parse open(input_file, &:read)
rules_counts = {}
array.each do |file|
next if file['errorCount'] == 0 && file['warningCount'] == 0
file['messages'].each do |message|
rules_counts[message['ruleId']] = 0 unless rules_counts[message['ruleId']]
rules_counts[message['ruleId']] += 1
end
end
results = rules_counts.sort_by { |_, v| -v }
File.open(output_file, 'w') do |f|
f.puts('{')
f.puts(' "rules" : {')
results.each { |rule, c| f.puts(" \"#{rule}\" : 0, // #{c} issues found") }
f.puts(' }')
f.puts('}')
end
@sumyapp
Copy link
Author

sumyapp commented Aug 15, 2016

最終行に,が入ってしまうのを手作業で削除が必要(current version(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment