8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/standard/runners/genignore.rb', line 8
def call(config)
temp_file = Tempfile.new("excluded.txt")
begin
config.rubocop_options[:formatters] = [["json", temp_file.path]]
config.rubocop_options[:out] = temp_file.path
exit_code = Runners::Rubocop.new.call(config)
result = JSON.parse(temp_file.read)
ignore = result["files"].select { |file|
file["offenses"].size > 0
}.map { |file|
{
file["path"] => file["offenses"].map { |o| o["cop_name"] }.uniq
}
}
yaml_format_errors = {"ignore" => ignore}
File.open(".standard_todo.yml", "w") do |file|
file.puts "# Auto generated files with errors to ignore."
file.puts "# Remove from this list as you refactor files."
file.write(yaml_format_errors.to_yaml)
end
exit_code
ensure
temp_file.close
temp_file.unlink
end
end
|