BaseFormatter
This formatter formats the report data in JSON format.
# File lib/rubocop/formatter/json_formatter.rb, line 26 def file_finished(file, offenses) output_hash[:files] << hash_for_file(file, offenses) output_hash[:summary][:offense_count] += offenses.count end
# File lib/rubocop/formatter/json_formatter.rb, line 31 def finished(inspected_files) output_hash[:summary][:inspected_file_count] = inspected_files.count output.write output_hash.to_json end
# File lib/rubocop/formatter/json_formatter.rb, line 46 def hash_for_file(file, offenses) { path: relative_path(file), offenses: offenses.map { |o| hash_for_offense(o) } } end
TODO: Consider better solution for Offense#real_column.
# File lib/rubocop/formatter/json_formatter.rb, line 64 def hash_for_location(offense) { line: offense.line, column: offense.real_column, length: offense.location.length } end
# File lib/rubocop/formatter/json_formatter.rb, line 53 def hash_for_offense(offense) { severity: offense.severity.name, message: offense.message, cop_name: offense.cop_name, corrected: offense.corrected?, location: hash_for_location(offense) } end
Generated with the Darkfish Rdoc Generator 2.